Loading crypto/engine/eng_openssl.c +55 −18 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ # undef TEST_ENG_OPENSSL_RC4_P_CIPHER #endif static int openssl_destroy(ENGINE *e); #ifdef TEST_ENG_OPENSSL_RC4 static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); Loading Loading @@ -144,6 +146,7 @@ static int bind_helper(ENGINE *e) { if (!ENGINE_set_id(e, engine_openssl_id) || !ENGINE_set_name(e, engine_openssl_name) || !ENGINE_set_destroy_function(e, openssl_destroy) #ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS # ifndef OPENSSL_NO_RSA || !ENGINE_set_RSA(e, RSA_get_default_method()) Loading Loading @@ -326,9 +329,7 @@ static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, #ifdef TEST_ENG_OPENSSL_SHA /* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */ # include <openssl/sha.h> static const int test_digest_nids[] = { NID_sha1 }; static const int test_digest_nids_number = 1; static int test_sha1_init(EVP_MD_CTX *ctx) { # ifdef TEST_ENG_OPENSSL_SHA_P_INIT Loading @@ -353,31 +354,60 @@ static int test_sha1_final(EVP_MD_CTX *ctx, unsigned char *md) return SHA1_Final(md, EVP_MD_CTX_md_data(ctx)); } static const EVP_MD test_sha_md = { NID_sha1, NID_sha1WithRSAEncryption, SHA_DIGEST_LENGTH, 0, test_sha1_init, test_sha1_update, test_sha1_final, NULL, NULL, SHA_CBLOCK, sizeof(EVP_MD *) + sizeof(SHA_CTX), }; static EVP_MD *sha1_md = NULL; static const EVP_MD *test_sha_md(void) { if (sha1_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_sha1, NID_sha1WithRSAEncryption)) == NULL || !EVP_MD_meth_set_result_size(md, SHA_DIGEST_LENGTH) || !EVP_MD_meth_set_input_blocksize(md, SHA_CBLOCK) || !EVP_MD_meth_set_app_datasize(md, sizeof(EVP_MD *) + sizeof(SHA_CTX)) || !EVP_MD_meth_set_flags(md, 0) || !EVP_MD_meth_set_init(md, test_sha1_init) || !EVP_MD_meth_set_update(md, test_sha1_update) || !EVP_MD_meth_set_final(md, test_sha1_final)) { EVP_MD_meth_free(md); md = NULL; } sha1_md = md; } return sha1_md; } static void test_sha_md_destroy(void) { EVP_MD_meth_free(sha1_md); sha1_md = NULL; } static int test_digest_nids(const int **nids) { static int digest_nids[2] = { 0, 0 }; static int pos = 0; static int init = 0; if (!init) { const EVP_MD *md; if ((md = test_sha_md()) != NULL) digest_nids[pos++] = EVP_MD_type(md); digest_nids[pos] = 0; init = 1; } *nids = digest_nids; return pos; } static int openssl_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid) { if (!digest) { /* We are returning a list of supported nids */ *nids = test_digest_nids; return test_digest_nids_number; return test_digest_nids(nids); } /* We are being asked for a specific digest */ if (nid == NID_sha1) *digest = &test_sha_md; *digest = test_sha_md(); else { # ifdef TEST_ENG_OPENSSL_SHA_OTHERS fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) returning NULL for " Loading Loading @@ -617,3 +647,10 @@ static int ossl_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth, } #endif int openssl_destroy(ENGINE *e) { test_sha_md_destroy(); return 1; } engines/ccgost/gost_crypt.c +31 −14 Original line number Diff line number Diff line Loading @@ -85,20 +85,37 @@ static int gost_imit_cleanup(EVP_MD_CTX *ctx); /* Control function, knows how to set MAC key.*/ static int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr); EVP_MD imit_gost_cpa = { NID_id_Gost28147_89_MAC, NID_undef, 4, 0, gost_imit_init_cpa, gost_imit_update, gost_imit_final, gost_imit_copy, gost_imit_cleanup, 8, sizeof(struct ossl_gost_imit_ctx), gost_imit_ctrl }; static EVP_MD *_hidden_Gost28147_89_MAC_md = NULL; EVP_MD *imit_gost_cpa(void) { if (_hidden_Gost28147_89_MAC_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_id_Gost28147_89_MAC, NID_undef)) == NULL || !EVP_MD_meth_set_result_size(md, 4) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) || !EVP_MD_meth_set_flags(md, 0) || !EVP_MD_meth_set_init(md, gost_imit_init_cpa) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) || !EVP_MD_meth_set_copy(md, gost_imit_copy) || !EVP_MD_meth_set_cleanup(md, gost_imit_cleanup) || !EVP_MD_meth_set_ctrl(md, gost_imit_ctrl)) { EVP_MD_meth_free(md); md = NULL; } _hidden_Gost28147_89_MAC_md = md; } return _hidden_Gost28147_89_MAC_md; } void imit_gost_cpa_destroy(void) { EVP_MD_meth_free(_hidden_Gost28147_89_MAC_md); _hidden_Gost28147_89_MAC_md = NULL; } /* * Correspondence between gost parameter OIDs and substitution blocks Loading engines/ccgost/gost_eng.c +26 −8 Original line number Diff line number Diff line Loading @@ -39,8 +39,24 @@ static int gost_pkey_asn1_meths(ENGINE *e, EVP_PKEY_ASN1_METHOD **ameth, static int gost_cipher_nids[] = { NID_id_Gost28147_89, NID_gost89_cnt, 0 }; static int gost_digest_nids[] = { NID_id_GostR3411_94, NID_id_Gost28147_89_MAC, 0 }; static int gost_digest_nids(const int **nids) { static int digest_nids[3] = { 0, 0, 0 }; static int pos = 0; static int init = 0; if (!init) { const EVP_MD *md; if ((md = digest_gost()) != NULL) digest_nids[pos++] = EVP_MD_type(md); if ((md = imit_gost_cpa()) != NULL) digest_nids[pos++] = EVP_MD_type(md); digest_nids[pos] = 0; init = 1; } *nids = digest_nids; return pos; } static EVP_PKEY_METHOD *pmeth_GostR3410_2001 = NULL; static EVP_PKEY_METHOD *pmeth_Gost28147_MAC = NULL; Loading @@ -60,6 +76,9 @@ static int gost_engine_finish(ENGINE *e) static int gost_engine_destroy(ENGINE *e) { digest_gost_destroy(); imit_gost_cpa_destroy(); gost_param_free(); pmeth_GostR3410_2001 = NULL; Loading Loading @@ -136,8 +155,8 @@ static int bind_gost(ENGINE *e, const char *id) /* These two actually should go in LIST_ADD command */ || !EVP_add_cipher(&cipher_gost) || !EVP_add_cipher(&cipher_gost_cpacnt) || !EVP_add_digest(&digest_gost) || !EVP_add_digest(&imit_gost_cpa) || !EVP_add_digest(digest_gost()) || !EVP_add_digest(imit_gost_cpa()) ) { goto end; } Loading @@ -157,16 +176,15 @@ static int gost_digests(ENGINE *e, const EVP_MD **digest, { int ok = 1; if (!digest) { *nids = gost_digest_nids; return 2; return gost_digest_nids(nids); } /* * printf("Digest no %d requested\n",nid); */ if (nid == NID_id_GostR3411_94) { *digest = &digest_gost; *digest = digest_gost(); } else if (nid == NID_id_Gost28147_89_MAC) { *digest = &imit_gost_cpa; *digest = imit_gost_cpa(); } else { ok = 0; *digest = NULL; Loading engines/ccgost/gost_lcl.h +4 −2 Original line number Diff line number Diff line Loading @@ -143,9 +143,11 @@ struct ossl_gost_digest_ctx { gost_ctx cctx; }; /* EVP_MD structure for GOST R 34.11 */ extern EVP_MD digest_gost; EVP_MD *digest_gost(void); void digest_gost_destroy(void); /* EVP_MD structure for GOST 28147 in MAC mode */ extern EVP_MD imit_gost_cpa; EVP_MD *imit_gost_cpa(void); void imit_gost_cpa_destroy(void); /* Cipher context used for EVP_CIPHER operation */ struct ossl_gost_cipher_ctx { int paramNID; Loading engines/ccgost/gost_md.c +29 −14 Original line number Diff line number Diff line Loading @@ -19,20 +19,35 @@ static int gost_digest_final(EVP_MD_CTX *ctx, unsigned char *md); static int gost_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from); static int gost_digest_cleanup(EVP_MD_CTX *ctx); EVP_MD digest_gost = { NID_id_GostR3411_94, NID_undef, 32, 0, gost_digest_init, gost_digest_update, gost_digest_final, gost_digest_copy, gost_digest_cleanup, 32, sizeof(struct ossl_gost_digest_ctx), NULL }; static EVP_MD *_hidden_GostR3411_94_md = NULL; EVP_MD *digest_gost(void) { if (_hidden_GostR3411_94_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_id_GostR3411_94, NID_undef)) == NULL || !EVP_MD_meth_set_result_size(md, 32) || !EVP_MD_meth_set_input_blocksize(md, 32) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_digest_ctx)) || !EVP_MD_meth_set_init(md, gost_digest_init) || !EVP_MD_meth_set_update(md, gost_digest_update) || !EVP_MD_meth_set_final(md, gost_digest_final) || !EVP_MD_meth_set_copy(md, gost_digest_copy) || !EVP_MD_meth_set_cleanup(md, gost_digest_cleanup)) { EVP_MD_meth_free(md); md = NULL; } _hidden_GostR3411_94_md = md; } return _hidden_GostR3411_94_md; } void digest_gost_destroy(void) { EVP_MD_meth_free(_hidden_GostR3411_94_md); _hidden_GostR3411_94_md = NULL; } int gost_digest_init(EVP_MD_CTX *ctx) { Loading Loading
crypto/engine/eng_openssl.c +55 −18 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ # undef TEST_ENG_OPENSSL_RC4_P_CIPHER #endif static int openssl_destroy(ENGINE *e); #ifdef TEST_ENG_OPENSSL_RC4 static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); Loading Loading @@ -144,6 +146,7 @@ static int bind_helper(ENGINE *e) { if (!ENGINE_set_id(e, engine_openssl_id) || !ENGINE_set_name(e, engine_openssl_name) || !ENGINE_set_destroy_function(e, openssl_destroy) #ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS # ifndef OPENSSL_NO_RSA || !ENGINE_set_RSA(e, RSA_get_default_method()) Loading Loading @@ -326,9 +329,7 @@ static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, #ifdef TEST_ENG_OPENSSL_SHA /* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */ # include <openssl/sha.h> static const int test_digest_nids[] = { NID_sha1 }; static const int test_digest_nids_number = 1; static int test_sha1_init(EVP_MD_CTX *ctx) { # ifdef TEST_ENG_OPENSSL_SHA_P_INIT Loading @@ -353,31 +354,60 @@ static int test_sha1_final(EVP_MD_CTX *ctx, unsigned char *md) return SHA1_Final(md, EVP_MD_CTX_md_data(ctx)); } static const EVP_MD test_sha_md = { NID_sha1, NID_sha1WithRSAEncryption, SHA_DIGEST_LENGTH, 0, test_sha1_init, test_sha1_update, test_sha1_final, NULL, NULL, SHA_CBLOCK, sizeof(EVP_MD *) + sizeof(SHA_CTX), }; static EVP_MD *sha1_md = NULL; static const EVP_MD *test_sha_md(void) { if (sha1_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_sha1, NID_sha1WithRSAEncryption)) == NULL || !EVP_MD_meth_set_result_size(md, SHA_DIGEST_LENGTH) || !EVP_MD_meth_set_input_blocksize(md, SHA_CBLOCK) || !EVP_MD_meth_set_app_datasize(md, sizeof(EVP_MD *) + sizeof(SHA_CTX)) || !EVP_MD_meth_set_flags(md, 0) || !EVP_MD_meth_set_init(md, test_sha1_init) || !EVP_MD_meth_set_update(md, test_sha1_update) || !EVP_MD_meth_set_final(md, test_sha1_final)) { EVP_MD_meth_free(md); md = NULL; } sha1_md = md; } return sha1_md; } static void test_sha_md_destroy(void) { EVP_MD_meth_free(sha1_md); sha1_md = NULL; } static int test_digest_nids(const int **nids) { static int digest_nids[2] = { 0, 0 }; static int pos = 0; static int init = 0; if (!init) { const EVP_MD *md; if ((md = test_sha_md()) != NULL) digest_nids[pos++] = EVP_MD_type(md); digest_nids[pos] = 0; init = 1; } *nids = digest_nids; return pos; } static int openssl_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid) { if (!digest) { /* We are returning a list of supported nids */ *nids = test_digest_nids; return test_digest_nids_number; return test_digest_nids(nids); } /* We are being asked for a specific digest */ if (nid == NID_sha1) *digest = &test_sha_md; *digest = test_sha_md(); else { # ifdef TEST_ENG_OPENSSL_SHA_OTHERS fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) returning NULL for " Loading Loading @@ -617,3 +647,10 @@ static int ossl_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth, } #endif int openssl_destroy(ENGINE *e) { test_sha_md_destroy(); return 1; }
engines/ccgost/gost_crypt.c +31 −14 Original line number Diff line number Diff line Loading @@ -85,20 +85,37 @@ static int gost_imit_cleanup(EVP_MD_CTX *ctx); /* Control function, knows how to set MAC key.*/ static int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr); EVP_MD imit_gost_cpa = { NID_id_Gost28147_89_MAC, NID_undef, 4, 0, gost_imit_init_cpa, gost_imit_update, gost_imit_final, gost_imit_copy, gost_imit_cleanup, 8, sizeof(struct ossl_gost_imit_ctx), gost_imit_ctrl }; static EVP_MD *_hidden_Gost28147_89_MAC_md = NULL; EVP_MD *imit_gost_cpa(void) { if (_hidden_Gost28147_89_MAC_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_id_Gost28147_89_MAC, NID_undef)) == NULL || !EVP_MD_meth_set_result_size(md, 4) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) || !EVP_MD_meth_set_flags(md, 0) || !EVP_MD_meth_set_init(md, gost_imit_init_cpa) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) || !EVP_MD_meth_set_copy(md, gost_imit_copy) || !EVP_MD_meth_set_cleanup(md, gost_imit_cleanup) || !EVP_MD_meth_set_ctrl(md, gost_imit_ctrl)) { EVP_MD_meth_free(md); md = NULL; } _hidden_Gost28147_89_MAC_md = md; } return _hidden_Gost28147_89_MAC_md; } void imit_gost_cpa_destroy(void) { EVP_MD_meth_free(_hidden_Gost28147_89_MAC_md); _hidden_Gost28147_89_MAC_md = NULL; } /* * Correspondence between gost parameter OIDs and substitution blocks Loading
engines/ccgost/gost_eng.c +26 −8 Original line number Diff line number Diff line Loading @@ -39,8 +39,24 @@ static int gost_pkey_asn1_meths(ENGINE *e, EVP_PKEY_ASN1_METHOD **ameth, static int gost_cipher_nids[] = { NID_id_Gost28147_89, NID_gost89_cnt, 0 }; static int gost_digest_nids[] = { NID_id_GostR3411_94, NID_id_Gost28147_89_MAC, 0 }; static int gost_digest_nids(const int **nids) { static int digest_nids[3] = { 0, 0, 0 }; static int pos = 0; static int init = 0; if (!init) { const EVP_MD *md; if ((md = digest_gost()) != NULL) digest_nids[pos++] = EVP_MD_type(md); if ((md = imit_gost_cpa()) != NULL) digest_nids[pos++] = EVP_MD_type(md); digest_nids[pos] = 0; init = 1; } *nids = digest_nids; return pos; } static EVP_PKEY_METHOD *pmeth_GostR3410_2001 = NULL; static EVP_PKEY_METHOD *pmeth_Gost28147_MAC = NULL; Loading @@ -60,6 +76,9 @@ static int gost_engine_finish(ENGINE *e) static int gost_engine_destroy(ENGINE *e) { digest_gost_destroy(); imit_gost_cpa_destroy(); gost_param_free(); pmeth_GostR3410_2001 = NULL; Loading Loading @@ -136,8 +155,8 @@ static int bind_gost(ENGINE *e, const char *id) /* These two actually should go in LIST_ADD command */ || !EVP_add_cipher(&cipher_gost) || !EVP_add_cipher(&cipher_gost_cpacnt) || !EVP_add_digest(&digest_gost) || !EVP_add_digest(&imit_gost_cpa) || !EVP_add_digest(digest_gost()) || !EVP_add_digest(imit_gost_cpa()) ) { goto end; } Loading @@ -157,16 +176,15 @@ static int gost_digests(ENGINE *e, const EVP_MD **digest, { int ok = 1; if (!digest) { *nids = gost_digest_nids; return 2; return gost_digest_nids(nids); } /* * printf("Digest no %d requested\n",nid); */ if (nid == NID_id_GostR3411_94) { *digest = &digest_gost; *digest = digest_gost(); } else if (nid == NID_id_Gost28147_89_MAC) { *digest = &imit_gost_cpa; *digest = imit_gost_cpa(); } else { ok = 0; *digest = NULL; Loading
engines/ccgost/gost_lcl.h +4 −2 Original line number Diff line number Diff line Loading @@ -143,9 +143,11 @@ struct ossl_gost_digest_ctx { gost_ctx cctx; }; /* EVP_MD structure for GOST R 34.11 */ extern EVP_MD digest_gost; EVP_MD *digest_gost(void); void digest_gost_destroy(void); /* EVP_MD structure for GOST 28147 in MAC mode */ extern EVP_MD imit_gost_cpa; EVP_MD *imit_gost_cpa(void); void imit_gost_cpa_destroy(void); /* Cipher context used for EVP_CIPHER operation */ struct ossl_gost_cipher_ctx { int paramNID; Loading
engines/ccgost/gost_md.c +29 −14 Original line number Diff line number Diff line Loading @@ -19,20 +19,35 @@ static int gost_digest_final(EVP_MD_CTX *ctx, unsigned char *md); static int gost_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from); static int gost_digest_cleanup(EVP_MD_CTX *ctx); EVP_MD digest_gost = { NID_id_GostR3411_94, NID_undef, 32, 0, gost_digest_init, gost_digest_update, gost_digest_final, gost_digest_copy, gost_digest_cleanup, 32, sizeof(struct ossl_gost_digest_ctx), NULL }; static EVP_MD *_hidden_GostR3411_94_md = NULL; EVP_MD *digest_gost(void) { if (_hidden_GostR3411_94_md == NULL) { EVP_MD *md; if ((md = EVP_MD_meth_new(NID_id_GostR3411_94, NID_undef)) == NULL || !EVP_MD_meth_set_result_size(md, 32) || !EVP_MD_meth_set_input_blocksize(md, 32) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_digest_ctx)) || !EVP_MD_meth_set_init(md, gost_digest_init) || !EVP_MD_meth_set_update(md, gost_digest_update) || !EVP_MD_meth_set_final(md, gost_digest_final) || !EVP_MD_meth_set_copy(md, gost_digest_copy) || !EVP_MD_meth_set_cleanup(md, gost_digest_cleanup)) { EVP_MD_meth_free(md); md = NULL; } _hidden_GostR3411_94_md = md; } return _hidden_GostR3411_94_md; } void digest_gost_destroy(void) { EVP_MD_meth_free(_hidden_GostR3411_94_md); _hidden_GostR3411_94_md = NULL; } int gost_digest_init(EVP_MD_CTX *ctx) { Loading