@@ -109,17 +109,48 @@ static const unsigned char openssl_public_rsa_stripped[] = {
109109 0x60 , 0x3f , 0x8b , 0x54 , 0x3a , 0xc3 , 0x4d , 0x31 , 0xe7 , 0x94 , 0xa4 , 0x44 , 0xfd , 0x02 , 0x03 , 0x01 ,
110110 0x00 , 0x01 , };
111111
112+
113+ /* generated with the private key above as:
114+ echo -n 'test' | openssl rsautl -sign -inkey rsa_private.pem -pkcs -hexdump
115+ */
116+ static const unsigned char openssl_rsautl_pkcs [] = {
117+ 0x24 , 0xef , 0x54 , 0xea , 0x1a , 0x12 , 0x0c , 0xf4 , 0x04 , 0x0c , 0x48 , 0xc8 , 0xe8 , 0x17 , 0xd2 , 0x6f ,
118+ 0xc3 , 0x41 , 0xb3 , 0x97 , 0x5c , 0xbc , 0xa3 , 0x2d , 0x21 , 0x00 , 0x10 , 0x0e , 0xbb , 0xf7 , 0x30 , 0x21 ,
119+ 0x7e , 0x12 , 0xd2 , 0xdf , 0x26 , 0x28 , 0xd8 , 0x0f , 0x6d , 0x4d , 0xc8 , 0x4d , 0xa8 , 0x78 , 0xe7 , 0x03 ,
120+ 0xee , 0xbc , 0x68 , 0xba , 0x98 , 0xea , 0xe9 , 0xb6 , 0x06 , 0x8d , 0x85 , 0x5b , 0xdb , 0xa6 , 0x49 , 0x86 ,
121+ 0x6f , 0xc7 , 0x3d , 0xe0 , 0x53 , 0x83 , 0xe0 , 0xea , 0xb1 , 0x08 , 0x6a , 0x7b , 0xbd , 0xeb , 0xb5 , 0x4a ,
122+ 0xdd , 0xbc , 0x64 , 0x97 , 0x8c , 0x17 , 0x20 , 0xa3 , 0x5c , 0xd4 , 0xb8 , 0x87 , 0x43 , 0xc5 , 0x13 , 0xad ,
123+ 0x41 , 0x6e , 0x45 , 0x41 , 0x32 , 0xd4 , 0x09 , 0x12 , 0x7f , 0xdc , 0x59 , 0x1f , 0x28 , 0x3f , 0x1e , 0xbc ,
124+ 0xef , 0x57 , 0x23 , 0x4b , 0x3a , 0xa3 , 0x24 , 0x91 , 0x4d , 0xfb , 0xb2 , 0xd4 , 0xe7 , 0x5e , 0x41 , 0x7e ,
125+ };
126+
112127extern const unsigned char _der_tests_cacert_root_cert [];
113128extern const unsigned long _der_tests_cacert_root_cert_size ;
114129
115130static int rsa_compat_test (void )
116131{
117- rsa_key key ;
132+ rsa_key key , pubkey ;
133+ int stat ;
118134 unsigned char buf [1024 ];
119135 unsigned long len ;
120136
121137 /* try reading the key */
122138 DO (rsa_import (openssl_private_rsa , sizeof (openssl_private_rsa ), & key ));
139+ DO (rsa_import (openssl_public_rsa , sizeof (openssl_public_rsa ), & pubkey ));
140+
141+ /* sign-verify a message with PKCS #1 v1.5 no ASN.1 */
142+ len = sizeof (buf );
143+ DO (rsa_sign_hash_ex ((unsigned char * )"test" , 4 , buf , & len , LTC_PKCS_1_V1_5_NA1 , NULL , 0 , 0 , 0 , & key ));
144+ if (len != sizeof (openssl_rsautl_pkcs ) || memcmp (buf , openssl_rsautl_pkcs , len )) {
145+ fprintf (stderr , "RSA rsa_sign_hash_ex + LTC_PKCS_1_V1_5_NA1 failed\n" );
146+ return 1 ;
147+ }
148+ stat = 0 ;
149+ DO (rsa_verify_hash_ex (openssl_rsautl_pkcs , sizeof (openssl_rsautl_pkcs ), (unsigned char * )"test" , 4 , LTC_PKCS_1_V1_5_NA1 , 0 , 0 , & stat , & pubkey ));
150+ if (stat != 1 ) {
151+ fprintf (stderr , "RSA rsa_verify_hash_ex + LTC_PKCS_1_V1_5_NA1 failed\n" );
152+ return 1 ;
153+ }
123154
124155 /* now try to export private/public and compare */
125156 len = sizeof (buf );
0 commit comments