From 7c7d7d67cefc52cf9706d370186423de45980a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 23 Dec 2025 00:42:26 +0100 Subject: [PATCH] 2025-12-23 00:42 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbssl/d2i.c * contrib/hbssl/hbssl.hbx * added new PRG function which converts ASN.1 DER SEQUENCE (RFC 3279) to IEEE P1363 Fixed Field Concatenation ( R || S ): D2I_ECDSA_SIG_RS( ) -> * src/rtl/vfile.c * comment formatting --- ChangeLog.txt | 10 ++++++++++ contrib/hbssl/d2i.c | 30 ++++++++++++++++++++++++++++++ contrib/hbssl/hbssl.hbx | 1 + src/rtl/vfile.c | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 028d927515..611eb4cb86 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,16 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2025-12-23 00:42 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbssl/d2i.c + * contrib/hbssl/hbssl.hbx + * added new PRG function which converts ASN.1 DER SEQUENCE (RFC 3279) to + IEEE P1363 Fixed Field Concatenation ( R || S ): + D2I_ECDSA_SIG_RS( ) -> + + * src/rtl/vfile.c + * comment formatting + 2025-12-21 12:06 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbssl/x509.c ! fixed compilation with OpenSSL < 1.1 diff --git a/contrib/hbssl/d2i.c b/contrib/hbssl/d2i.c index 5a65580f06..2b55646d26 100644 --- a/contrib/hbssl/d2i.c +++ b/contrib/hbssl/d2i.c @@ -99,3 +99,33 @@ HB_FUNC( D2I_X509 ) else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } + +HB_FUNC( D2I_ECDSA_SIG_RS ) +{ + HB_SSL_CONST unsigned char * pszSigDer = ( HB_SSL_CONST unsigned char * ) hb_parc( 1 ); + + if( pszSigDer ) + { + #define EC_P256_LEN 32 + unsigned char rawsig[ EC_P256_LEN * 2 ]; + HB_SIZE len = 0; + +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + ECDSA_SIG * sig = d2i_ECDSA_SIG( NULL, &pszSigDer, ( long ) hb_parclen( 1 ) ); + + if( sig ) + { + const BIGNUM *r, *s; + + ECDSA_SIG_get0(sig, &r, &s); + if( BN_bn2binpad( r, rawsig, EC_P256_LEN ) == EC_P256_LEN && + BN_bn2binpad( s, rawsig + EC_P256_LEN, EC_P256_LEN ) == EC_P256_LEN ) + len = EC_P256_LEN * 2; + ECDSA_SIG_free( sig ); + } +#endif + hb_retclen( ( const char * ) rawsig, len ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} diff --git a/contrib/hbssl/hbssl.hbx b/contrib/hbssl/hbssl.hbx index 71205a94c2..3994e6b4ea 100644 --- a/contrib/hbssl/hbssl.hbx +++ b/contrib/hbssl/hbssl.hbx @@ -72,6 +72,7 @@ DYNAMIC BIO_tell DYNAMIC BIO_test_flags DYNAMIC BIO_vfree DYNAMIC BIO_write +DYNAMIC D2I_ECDSA_SIG_RS DYNAMIC D2I_PUBKEY DYNAMIC D2I_RSAPUBLICKEY DYNAMIC D2I_X509 diff --git a/src/rtl/vfile.c b/src/rtl/vfile.c index 0b2922fc4b..4558d543e3 100644 --- a/src/rtl/vfile.c +++ b/src/rtl/vfile.c @@ -918,7 +918,7 @@ HB_FUNC( HB_VFLOAD ) hb_errRT_BASE_SubstR( EG_ARG, 2021, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -/* hb_vfSave( , ) --> */ +/* hb_vfSave( , ) --> */ HB_FUNC( HB_VFSAVE ) { const char * pszFileName = hb_parc( 1 );