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 const EVP_CIPHER *GetCipher(const std::string &name); 29 30 bool CipherOperation(const EVP_CIPHER *cipher, std::vector<uint8_t> *out, 31 bool encrypt, const std::vector<uint8_t> &key, 32 const std::vector<uint8_t> &iv, 33 const std::vector<uint8_t> &in); 34 35 bool AEADEncrypt(const EVP_AEAD *aead, std::vector<uint8_t> *ct, 36 std::vector<uint8_t> *tag, size_t tag_len, 37 const std::vector<uint8_t> &key, 38 const std::vector<uint8_t> &pt, 39 const std::vector<uint8_t> &aad, 40 const std::vector<uint8_t> &iv); 41 42 bool AEADDecrypt(const EVP_AEAD *aead, std::vector<uint8_t> *pt, size_t pt_len, 43 const std::vector<uint8_t> &key, 44 const std::vector<uint8_t> &aad, 45 const std::vector<uint8_t> &ct, 46 const std::vector<uint8_t> &tag, 47 const std::vector<uint8_t> &iv); 48 49 bssl::UniquePtr<BIGNUM> GetBIGNUM(FileTest *t, const char *attribute); 50 51 int GetECGroupNIDFromInstruction(FileTest *t, const char **out_str = nullptr); 52 53 const EVP_MD *GetDigestFromInstruction(FileTest *t); 54 55 void EchoComment(const std::string& comment); 56 57 int cavp_aes_gcm_test_main(int argc, char **argv); 58 int cavp_aes_test_main(int argc, char **argv); 59 int cavp_ctr_drbg_test_main(int argc, char **argv); 60 int cavp_ecdsa2_keypair_test_main(int argc, char **argv); 61 int cavp_ecdsa2_pkv_test_main(int argc, char **argv); 62 int cavp_ecdsa2_siggen_test_main(int argc, char **argv); 63 int cavp_ecdsa2_sigver_test_main(int argc, char **argv); 64 int cavp_hmac_test_main(int argc, char **argv); 65 int cavp_kas_test_main(int argc, char **argv); 66 int cavp_keywrap_test_main(int argc, char **argv); 67 int cavp_rsa2_keygen_test_main(int argc, char **argv); 68 int cavp_rsa2_siggen_test_main(int argc, char **argv); 69 int cavp_rsa2_sigver_test_main(int argc, char **argv); 70 int cavp_sha_monte_test_main(int argc, char **argv); 71 int cavp_sha_test_main(int argc, char **argv); 72 int cavp_tdes_test_main(int argc, char **argv); 73 int cavp_tlskdf_test_main(int argc, char **argv); 74 75 76 #endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_CAVP_TEST_UTIL_H 77