| 1202 | |
| 1203 | |
| 1204 | int dh_test() |
| 1205 | { |
| 1206 | Source source; |
| 1207 | FileSource("../certs/dh1024.dat", source); |
| 1208 | if (source.size() == 0) { |
| 1209 | FileSource("../../certs/dh1024.dat", source); // for testsuite |
| 1210 | if (source.size() == 0) { |
| 1211 | FileSource("../../../certs/dh1024.dat", source); // win32 Debug dir |
| 1212 | if (source.size() == 0) |
| 1213 | err_sys("where's your certs dir?", -79); |
| 1214 | } |
| 1215 | } |
| 1216 | HexDecoder hDec(source); |
| 1217 | |
| 1218 | DH dh(source); |
| 1219 | |
| 1220 | byte pub[128]; |
| 1221 | byte priv[128]; |
| 1222 | byte agree[128]; |
| 1223 | byte pub2[128]; |
| 1224 | byte priv2[128]; |
| 1225 | byte agree2[128]; |
| 1226 | |
| 1227 | DH dh2(dh); |
| 1228 | |
| 1229 | dh.GenerateKeyPair(rng, priv, pub); |
| 1230 | dh2.GenerateKeyPair(rng, priv2, pub2); |
| 1231 | dh.Agree(agree, priv, pub2); |
| 1232 | dh2.Agree(agree2, priv2, pub); |
| 1233 | |
| 1234 | |
| 1235 | if ( memcmp(agree, agree2, dh.GetByteLength()) ) |
| 1236 | return -80; |
| 1237 | |
| 1238 | return 0; |
| 1239 | } |
| 1240 | |
| 1241 | |
| 1242 | int dsa_test() |
no test coverage detected