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 25 #include "../crypto/test/file_test.h" 26 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, 41 const std::vector<uint8_t> &aad, 42 const std::vector<uint8_t> &iv); 43 44 bool AEADDecrypt(const EVP_AEAD *aead, std::vector<uint8_t> *pt, size_t pt_len, 45 const std::vector<uint8_t> &key, 46 const std::vector<uint8_t> &aad, 47 const std::vector<uint8_t> &ct, 48 const std::vector<uint8_t> &tag, 49 const std::vector<uint8_t> &iv); 50 51 bssl::UniquePtr<BIGNUM> GetBIGNUM(FileTest *t, const char *attribute); 52 53 int GetECGroupNIDFromInstruction(FileTest *t, const char **out_str = nullptr); 54 55 const EVP_MD *GetDigestFromInstruction(FileTest *t); 56 57 void EchoComment(const std::string& comment); 58 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_kas_test_main(int argc, char **argv); 68 int cavp_keywrap_test_main(int argc, char **argv); 69 int cavp_rsa2_keygen_test_main(int argc, char **argv); 70 int cavp_rsa2_siggen_test_main(int argc, char **argv); 71 int cavp_rsa2_sigver_test_main(int argc, char **argv); 72 int cavp_sha_monte_test_main(int argc, char **argv); 73 int cavp_sha_test_main(int argc, char **argv); 74 int cavp_tdes_test_main(int argc, char **argv); 75 int cavp_tlskdf_test_main(int argc, char **argv); 76 77 78 #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_CAVP_TEST_UTIL_H 79