| 177 | } |
| 178 | |
| 179 | bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough = false) |
| 180 | { |
| 181 | bool pass = true, fail; |
| 182 | |
| 183 | fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2); |
| 184 | pass = pass && !fail; |
| 185 | |
| 186 | cout << (fail ? "FAILED " : "passed "); |
| 187 | cout << "cryptosystem key validation\n"; |
| 188 | |
| 189 | const byte *message = (byte *)"test message"; |
| 190 | const int messageLen = 12; |
| 191 | SecByteBlock ciphertext(priv.CiphertextLength(messageLen)); |
| 192 | SecByteBlock plaintext(priv.MaxPlaintextLength(ciphertext.size())); |
| 193 | |
| 194 | pub.Encrypt(GlobalRNG(), message, messageLen, ciphertext); |
| 195 | fail = priv.Decrypt(GlobalRNG(), ciphertext, priv.CiphertextLength(messageLen), plaintext) != DecodingResult(messageLen); |
| 196 | fail = fail || memcmp(message, plaintext, messageLen); |
| 197 | pass = pass && !fail; |
| 198 | |
| 199 | cout << (fail ? "FAILED " : "passed "); |
| 200 | cout << "encryption and decryption\n"; |
| 201 | |
| 202 | return pass; |
| 203 | } |
| 204 | |
| 205 | bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d) |
| 206 | { |
no test coverage detected