EVP_SignInit_ex - HBSSL problem
Posted: Mon Dec 18, 2017 9:10 pm
Hi, I'm trying to use "EVP_SignInit_ex" but when I run the program it returns the sig variable empty. The "PEM_READ_BIO_RSAPRIVATEKEY" works fine, but the signing routine does not.
Hola, Estoy tratando de usar "EVP_SignInit_ex" pero cuando ejecuto el programa me retirna vacia la variable "sig". El
"PEM_READ_BIO_RSAPRIVATEKEY" funciona bien, pero la rutina de firmado no.
Thanks/Gracias
Diego.
Hola, Estoy tratando de usar "EVP_SignInit_ex" pero cuando ejecuto el programa me retirna vacia la variable "sig". El
"PEM_READ_BIO_RSAPRIVATEKEY" funciona bien, pero la rutina de firmado no.
- Code: Select all Expand view
#include "hbssl.ch"
Function main( )
Local cTx, signed, txt, sig , cString, privatekeym, bioe
setmode(25,80)
clear
#pragma __cstream|cString:=%s
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,7EDF8C06409FC8D1
w2i5vWLCOvrExPC4+FMwGQBwxXdGE7FY5Jgr6UstEN+b6l7UVSdRXEkT/Ng6RDZF
jViFPKBSrTAzEnvyNesqPBZMwRPKSEZSj+XcS/dHoz7hrbFTNBzKmDL8CJ67k2Lw
4UwtTtmTkU6L++NTfP6ImvxfaQYCkFK9D42qB7pzAAA27aGZMJCotECqVrekeCed
Tx7EMa7Vf2ToGTsvHBphy7Nwe/8Kijdb0wQIj0ZQWGa2vkYjICauAz9vfOv1xaXe
+H90c6xhVqRCv0uum3pGkqsrdJm0mBnr1gstFEDI+S1Lwr80WWBSQjCBsytfxc8j
dNXG8qXm59/n01vfHaZTtStd6mVa+eJwNRMHP0pisoxCTBPTtF/LOaZvOlbYB+r4
Hbxs5Bp0+YZp9RIipA3uagvtcTk7oHzx6v72amd3egli/DL1OY/ZjvVzHe9/dh6K
LZE2mpAHXtnHe8Rlg4CSPMvyFgN2OZXfbc64FjZcglldIoLwhr7kuLzb0zWv8sOz
jOO+uKNzyjDl5R2ay9YCANUpWVGOrpRrU6C/TzbltcxyEVKk8riKAKCsYf+De3Ee
SwPgouYGV8RgfzAwhwesibA1By1cLS/alCESH+9P2R39VHPB7MzjLc8FyNe3xAQJ
VGue9TIkMgy7RW1VFWLcLsCArTEAl83bv+BQ+YaPp9aLNq8bL5vfU2od0R7LXIOe
jH09fWcojNNLfmZU0Jzy7viUiScTtNqpqoH0qPI1hkisvELqXKhW1Lpkr56Ij8IL
B0NDIZKbaPJHHPb9Ne7nQECzv0/kzmAley9UMTZ1M7fq6KYemR0LsA==
-----END RSA PRIVATE KEY-----
#pragma __endtext
SSL_INIT()
ERR_load_PEM_strings()
OpenSSL_add_all_algorithms()
OpenSSL_add_all_ciphers()
PrivateKey := EVP_PKEY_NEW()
bioe := BIO_new_fd( 1, HB_BIO_NOCLOSE )
keyPtr := PEM_READ_BIO_RSAPRIVATEKEY( bio := BIO_new_mem_buf( cString ), "test" )
? ; ERR_print_errors( bioe ) //show if any error
EVP_PKEY_ASSIGN_RSA(PrivateKey,keyptr)
ctx := EVP_MD_CTX_create()
EVP_MD_CTX_init( ctx )
txt := "text to sign"
signed := ""
EVP_SignInit_ex(ctx, HB_EVP_MD_SHA1)
EVP_SignUpdate(ctx, txt )
EVP_SignFinal(ctx, @signed, PrivateKey)
sig := HB_BASE64ENCODE(signed)
? sig
return
Thanks/Gracias
Diego.