Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2017, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_CAVP_TEST_UTIL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_FIPSMODULE_CAVP_TEST_UTIL_H |
| 17 | |
| 18 | #include <stdlib.h> |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
| 22 | #include <openssl/aead.h> |
| 23 | #include <openssl/cipher.h> |
| 24 | |
Adam Langley | 58e4499 | 2017-04-28 16:45:49 -0700 | [diff] [blame] | 25 | #include "../crypto/test/file_test.h" |
David Benjamin | 90801c1 | 2017-04-28 17:08:45 -0400 | [diff] [blame] | 26 | |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 27 | |
| 28 | std::string EncodeHex(const uint8_t *in, size_t in_len); |
| 29 | |
| 30 | const EVP_CIPHER *GetCipher(const std::string &name); |
| 31 | |
| 32 | bool CipherOperation(const EVP_CIPHER *cipher, std::vector<uint8_t> *out, |
| 33 | bool encrypt, const std::vector<uint8_t> &key, |
| 34 | const std::vector<uint8_t> &iv, |
| 35 | const std::vector<uint8_t> &in); |
| 36 | |
| 37 | bool AEADEncrypt(const EVP_AEAD *aead, std::vector<uint8_t> *ct, |
| 38 | std::vector<uint8_t> *tag, size_t tag_len, |
| 39 | const std::vector<uint8_t> &key, |
| 40 | const std::vector<uint8_t> &pt, |
Adam Langley | 563924b | 2017-05-30 11:43:25 -0700 | [diff] [blame] | 41 | const std::vector<uint8_t> &aad, |
| 42 | const std::vector<uint8_t> &iv); |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 43 | |
Adam Langley | 563924b | 2017-05-30 11:43:25 -0700 | [diff] [blame] | 44 | bool AEADDecrypt(const EVP_AEAD *aead, std::vector<uint8_t> *pt, size_t pt_len, |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 45 | const std::vector<uint8_t> &key, |
Adam Langley | 563924b | 2017-05-30 11:43:25 -0700 | [diff] [blame] | 46 | const std::vector<uint8_t> &aad, |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 47 | const std::vector<uint8_t> &ct, |
Adam Langley | 563924b | 2017-05-30 11:43:25 -0700 | [diff] [blame] | 48 | const std::vector<uint8_t> &tag, |
| 49 | const std::vector<uint8_t> &iv); |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 50 | |
David Benjamin | 90801c1 | 2017-04-28 17:08:45 -0400 | [diff] [blame] | 51 | bssl::UniquePtr<BIGNUM> GetBIGNUM(FileTest *t, const char *attribute); |
| 52 | |
David Benjamin | eb59989 | 2017-05-01 14:56:22 -0400 | [diff] [blame] | 53 | int GetECGroupNIDFromInstruction(FileTest *t, const char **out_str = nullptr); |
David Benjamin | 90801c1 | 2017-04-28 17:08:45 -0400 | [diff] [blame] | 54 | |
David Benjamin | 0c292ed | 2017-04-28 17:41:28 -0400 | [diff] [blame] | 55 | const EVP_MD *GetDigestFromInstruction(FileTest *t); |
| 56 | |
Adam Langley | d79bc9d | 2017-05-30 15:37:27 -0700 | [diff] [blame] | 57 | void EchoComment(const std::string& comment); |
| 58 | |
Martin Kreichgauer | ddfcc6a | 2017-05-03 14:12:39 -0700 | [diff] [blame] | 59 | int cavp_aes_gcm_test_main(int argc, char **argv); |
| 60 | int cavp_aes_test_main(int argc, char **argv); |
| 61 | int cavp_ctr_drbg_test_main(int argc, char **argv); |
| 62 | int cavp_ecdsa2_keypair_test_main(int argc, char **argv); |
| 63 | int cavp_ecdsa2_pkv_test_main(int argc, char **argv); |
| 64 | int cavp_ecdsa2_siggen_test_main(int argc, char **argv); |
| 65 | int cavp_ecdsa2_sigver_test_main(int argc, char **argv); |
| 66 | int cavp_hmac_test_main(int argc, char **argv); |
| 67 | int cavp_keywrap_test_main(int argc, char **argv); |
| 68 | int cavp_rsa2_keygen_test_main(int argc, char **argv); |
| 69 | int cavp_rsa2_siggen_test_main(int argc, char **argv); |
| 70 | int cavp_rsa2_sigver_test_main(int argc, char **argv); |
| 71 | int cavp_sha_monte_test_main(int argc, char **argv); |
| 72 | int cavp_sha_test_main(int argc, char **argv); |
| 73 | int cavp_tdes_test_main(int argc, char **argv); |
| 74 | |
Martin Kreichgauer | 7c12587 | 2017-04-24 13:29:11 -0700 | [diff] [blame] | 75 | |
| 76 | #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_CAVP_TEST_UTIL_H |