@@ -992,25 +992,25 @@ TEST(RSATest, CheckKey) {
992
992
static int rsa_priv_enc (int max_out, const uint8_t *from, uint8_t *to, RSA *rsa,
993
993
int padding) {
994
994
RSA_set_ex_data (rsa, 0 , (void *)" rsa_priv_enc" );
995
- return 1 ;
995
+ return 0 ;
996
996
}
997
997
998
998
static int rsa_priv_dec (int max_out, const uint8_t *from, uint8_t *to, RSA *rsa,
999
999
int padding) {
1000
1000
RSA_set_ex_data (rsa, 0 , (void *)" rsa_priv_dec" );
1001
- return 1 ;
1001
+ return 0 ;
1002
1002
}
1003
1003
1004
1004
static int rsa_pub_enc (int max_out, const uint8_t *from, uint8_t *to, RSA *rsa,
1005
1005
int padding) {
1006
1006
RSA_set_ex_data (rsa, 0 , (void *)" rsa_pub_enc" );
1007
- return 1 ;
1007
+ return 0 ;
1008
1008
}
1009
1009
1010
1010
static int rsa_pub_dec (int max_out, const uint8_t *from, uint8_t *to, RSA *rsa,
1011
1011
int padding) {
1012
1012
RSA_set_ex_data (rsa, 0 , (void *)" rsa_pub_dec" );
1013
- return 1 ;
1013
+ return 0 ;
1014
1014
}
1015
1015
1016
1016
static int extkey_rsa_finish (RSA *rsa) {
@@ -1038,9 +1038,9 @@ TEST(RSATest, RSAMETHOD) {
1038
1038
ASSERT_TRUE (RSA_meth_set_pub_dec (rsa_meth, rsa_pub_dec));
1039
1039
ASSERT_TRUE (RSA_meth_set_priv_enc (rsa_meth, rsa_priv_enc));
1040
1040
ASSERT_TRUE (RSA_meth_set_priv_dec (rsa_meth, rsa_priv_dec));
1041
- ASSERT_TRUE (RSA_meth_set_init (rsa_meth, NULL ));
1041
+ ASSERT_TRUE (RSA_meth_set_init (rsa_meth, nullptr ));
1042
1042
ASSERT_TRUE (RSA_meth_set_finish (rsa_meth, extkey_rsa_finish));
1043
- ASSERT_TRUE (RSA_meth_set0_app_data (rsa_meth, NULL ));
1043
+ ASSERT_TRUE (RSA_meth_set0_app_data (rsa_meth, nullptr ));
1044
1044
1045
1045
ASSERT_TRUE (rsa_meth->decrypt && rsa_meth->encrypt && rsa_meth->sign_raw &&
1046
1046
rsa_meth->verify_raw );
@@ -1062,20 +1062,36 @@ TEST(RSATest, RSAMETHOD) {
1062
1062
uint8_t in, out;
1063
1063
ASSERT_TRUE (EVP_PKEY_encrypt_init (rsa_key_ctx.get ()));
1064
1064
ASSERT_TRUE (EVP_PKEY_encrypt (rsa_key_ctx.get (), &out, &out_len, &in, 0 ));
1065
+ // Custom func return 0 since they don't write any data to out
1066
+ ASSERT_EQ (out_len, (size_t )0 );
1065
1067
ASSERT_STREQ (static_cast <const char *>(RSA_get_ex_data (key, 0 ))
1066
1068
, " rsa_pub_enc" );
1069
+
1070
+ // Update before passing into next operation
1071
+ out_len = EVP_PKEY_size (rsa_key.get ());
1067
1072
ASSERT_TRUE (EVP_PKEY_decrypt_init (rsa_key_ctx.get ()));
1068
1073
ASSERT_TRUE (EVP_PKEY_decrypt (rsa_key_ctx.get (), &out, &out_len, &in, 0 ));
1074
+ // Custom func return 0 since they don't write any data to out
1075
+ ASSERT_EQ (out_len, (size_t )0 );
1069
1076
ASSERT_STREQ (static_cast <const char *>(RSA_get_ex_data (key, 0 ))
1070
1077
, " rsa_priv_dec" );
1071
1078
1079
+ // Update before passing into next operation
1080
+ out_len = EVP_PKEY_size (rsa_key.get ());
1072
1081
ASSERT_TRUE (EVP_PKEY_verify_recover_init (rsa_key_ctx.get ()));
1073
- ASSERT_TRUE (EVP_PKEY_verify_recover (rsa_key_ctx.get (), &out, &out_len, NULL , 0 ));
1082
+ ASSERT_TRUE (EVP_PKEY_verify_recover (rsa_key_ctx.get (), &out, &out_len,
1083
+ nullptr , 0 ));
1084
+ // Custom func return 0 since they don't write any data to out
1085
+ ASSERT_EQ (out_len, (size_t )0 );
1074
1086
ASSERT_STREQ (static_cast <const char *>(RSA_get_ex_data (key, 0 ))
1075
1087
, " rsa_pub_dec" );
1076
1088
1089
+ // Update before passing into next operation
1090
+ out_len = EVP_PKEY_size (rsa_key.get ());
1077
1091
// This operation is not plumbed through EVP_PKEY API in OpenSSL or AWS-LC
1078
- ASSERT_TRUE (RSA_sign_raw (key, &out_len, &out, 0 , NULL , 0 , 0 ));
1092
+ ASSERT_TRUE (RSA_sign_raw (key, &out_len, &out, 0 , nullptr , 0 , 0 ));
1093
+ // Custom func return 0 since they don't write any data to out
1094
+ ASSERT_EQ (out_len, (size_t )0 );
1079
1095
ASSERT_STREQ (static_cast <const char *>(RSA_get_ex_data (key, 0 ))
1080
1096
, " rsa_priv_enc" );
1081
1097
}
0 commit comments