Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2631-Update-the-engine-test-suite.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2631-Update-the-engine-test-suite.patch of Package erlang
From 67837112b85f64cfd878f7bbb08fa4a9e97f41bd Mon Sep 17 00:00:00 2001 From: Lars Thorsen <lars@erlang.org> Date: Fri, 14 Oct 2022 10:23:45 +0200 Subject: [PATCH] Update the engine test suite - Add a test case for sign/verify with edsca - Add some printout from the test engine --- lib/crypto/c_src/otp_test_engine.c | 24 ++++++++++--------- lib/crypto/test/engine_SUITE.erl | 17 ++++++++++--- .../pkcs8/eddsa_private_key.pem | 3 +++ .../pkcs8/eddsa_public_key.pem | 3 +++ 4 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_private_key.pem create mode 100644 lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_public_key.pem diff --git a/lib/crypto/c_src/otp_test_engine.c b/lib/crypto/c_src/otp_test_engine.c index d3520de26e..1530ad311c 100644 --- a/lib/crypto/c_src/otp_test_engine.c +++ b/lib/crypto/c_src/otp_test_engine.c @@ -91,7 +91,7 @@ EVP_PKEY* test_key_load(ENGINE *er, const char *id, UI_METHOD *ui_method, void * static int test_init(ENGINE *e) { printf("OTP Test Engine Initializatzion!\r\n"); - + #if defined(FAKE_RSA_IMPL) if (!RSA_meth_set_finish(test_rsa_method, test_rsa_free)) goto err; @@ -253,7 +253,7 @@ static int test_engine_digest_selector(ENGINE *e, const EVP_MD **digest, else { goto err; } - + return 1; err: @@ -326,6 +326,8 @@ EVP_PKEY* test_key_load(ENGINE *eng, const char *id, UI_METHOD *ui_method, void EVP_PKEY *pkey = NULL; FILE *f = fopen(id, "r"); + fprintf(stderr, "%s:%d test_key_load(id=%s,priv=%d)\r\n", __FILE__,__LINE__,id, priv); + if (!f) { fprintf(stderr, "%s:%d fopen(%s) failed\r\n", __FILE__,__LINE__,id); return NULL; @@ -337,10 +339,10 @@ EVP_PKEY* test_key_load(ENGINE *eng, const char *id, UI_METHOD *ui_method, void : PEM_read_PUBKEY(f, NULL, NULL, NULL); fclose(f); - + if (!pkey) { fprintf(stderr, "%s:%d Key read from file %s failed.\r\n", __FILE__,__LINE__,id); - if (callback_data) + if (callback_data) fprintf(stderr, "Pwd = \"%s\".\r\n", (char *)callback_data); fprintf(stderr, "Contents of file \"%s\":\r\n",id); f = fopen(id, "r"); @@ -358,13 +360,13 @@ EVP_PKEY* test_key_load(ENGINE *eng, const char *id, UI_METHOD *ui_method, void fclose(f); return NULL; } - + return pkey; } -int pem_passwd_cb_fun(char *buf, int size, int rwflag, void *password) -{ +int pem_passwd_cb_fun(char *buf, int size, int rwflag, void *password) +{ size_t i; if (size < 0) @@ -396,10 +398,10 @@ int pem_passwd_cb_fun(char *buf, int size, int rwflag, void *password) static unsigned char fake_flag[] = {255,3,124,180,35,10,180,151,101,247,62,59,80,122,220, 142,24,180,191,34,51,150,112,27,43,142,195,60,245,213,80,179}; -int test_rsa_sign(int dtype, +int test_rsa_sign(int dtype, /* The digest to sign */ const unsigned char *m, unsigned int m_len, - /* The allocated buffer to fill with the signature */ + /* The allocated buffer to fill with the signature */ unsigned char *sigret, unsigned int *siglen, /* The key */ const RSA *rsa) @@ -435,10 +437,10 @@ int test_rsa_sign(int dtype, return -1; } -int test_rsa_verify(int dtype, +int test_rsa_verify(int dtype, /* The digest to verify */ const unsigned char *m, unsigned int m_len, - /* The signature */ + /* The signature */ const unsigned char *sigret, unsigned int siglen, /* The key */ const RSA *rsa) diff --git a/lib/crypto/test/engine_SUITE.erl b/lib/crypto/test/engine_SUITE.erl index 24e1da7aca..8907d3968f 100644 --- a/lib/crypto/test/engine_SUITE.erl +++ b/lib/crypto/test/engine_SUITE.erl @@ -65,6 +65,7 @@ sign_verify_rsa_fake/1, sign_verify_dsa/1, sign_verify_ecdsa/1, + sign_verify_eddsa/1, sign_verify_rsa_pwd/1, sign_verify_rsa_pwd_bad_pwd/1, priv_encrypt_pub_decrypt_rsa/1, @@ -113,6 +114,7 @@ groups() -> sign_verify_rsa, sign_verify_dsa, sign_verify_ecdsa, + sign_verify_eddsa, sign_verify_rsa_pwd, sign_verify_rsa_pwd_bad_pwd, priv_encrypt_pub_decrypt_rsa, @@ -126,9 +128,11 @@ groups() -> get_pub_from_priv_key_dsa, get_pub_from_priv_key_ecdsa ]}, - {engine_fakes_rsa, [], [sign_verify_rsa_fake - ]} - ]. + {engine_fakes_rsa, [], + [ + sign_verify_rsa_fake + ]} + ]. init_per_suite(Config) -> @@ -815,6 +819,13 @@ sign_verify_ecdsa(Config) -> key_id => key_id(Config, "ecdsa_public_key.pem")}, sign_verify(ecdsa, sha, Priv, Pub). +sign_verify_eddsa(Config) -> + Priv = #{engine => engine_ref(Config), + key_id => key_id(Config, "eddsa_private_key.pem")}, + Pub = #{engine => engine_ref(Config), + key_id => key_id(Config, "eddsa_public_key.pem")}, + sign_verify(eddsa, sha, Priv, Pub). + sign_verify_rsa_pwd(Config) -> Priv = #{engine => engine_ref(Config), key_id => key_id(Config, "rsa_private_key_pwd.pem"), diff --git a/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_private_key.pem b/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_private_key.pem new file mode 100644 index 0000000000..6e2eb18bdd --- /dev/null +++ b/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_private_key.pem @@ -0,0 +1,3 @@ +-----BEGIN PRIVATE KEY----- +MC4CAQAwBQYDK2VwBCIEIH8U4DpDNRXUDqYK8tYrlcOXPwx4Y6hrWfMpvvd7AioY +-----END PRIVATE KEY----- diff --git a/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_public_key.pem b/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_public_key.pem new file mode 100644 index 0000000000..f5728f5708 --- /dev/null +++ b/lib/crypto/test/engine_SUITE_data/pkcs8/eddsa_public_key.pem @@ -0,0 +1,3 @@ +-----BEGIN PUBLIC KEY----- +MCowBQYDK2VwAyEAM/95MNGrel/42ymyPnyOMh1Yfglw8WZ9KPpMajSQBHE= +-----END PUBLIC KEY----- -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor