@@ -54,10 +54,10 @@ class PKCS12Signer::Private
5454PKCS12Signer::PKCS12Signer (const string &path, const string &pass)
5555 : d(make_unique<Private>())
5656{
57- auto bio = SCOPE_PTR (BIO, BIO_new_file (path.c_str (), " rb" ));
57+ auto bio = make_unique_ptr<BIO_free>( BIO_new_file (path.c_str (), " rb" ));
5858 if (!bio)
5959 THROW_OPENSSLEXCEPTION (" Failed to open PKCS12 certificate: %s." , path.c_str ());
60- auto p12 = SCOPE_PTR (PKCS12, d2i_PKCS12_bio (bio.get (), nullptr ));
60+ auto p12 = make_unique_ptr<PKCS12_free>( d2i_PKCS12_bio (bio.get (), nullptr ));
6161 if (!p12)
6262 THROW_OPENSSLEXCEPTION (" Failed to read PKCS12 certificate: %s." , path.c_str ());
6363 if (!PKCS12_parse (p12.get (), pass.c_str (), &d->key , &d->cert , nullptr ))
@@ -82,7 +82,7 @@ vector<unsigned char> PKCS12Signer::sign(const string &method, const vector<unsi
8282 int result = 0 ;
8383 vector<unsigned char > signature;
8484 size_t size = 0 ;
85- SCOPE (EVP_PKEY_CTX, ctx, EVP_PKEY_CTX_new (d->key , nullptr ));
85+ auto ctx = make_unique_ptr<EVP_PKEY_CTX_free>( EVP_PKEY_CTX_new (d->key , nullptr ));
8686 if (!ctx || EVP_PKEY_sign_init (ctx.get ()) <= 0 )
8787 THROW_OPENSSLEXCEPTION (" Failed to sign the digest" );
8888 switch (EVP_PKEY_base_id (d->key ))
@@ -111,8 +111,7 @@ vector<unsigned char> PKCS12Signer::sign(const string &method, const vector<unsi
111111 result = EVP_PKEY_sign (ctx.get (), asn1.data (), &size, digest.data (), digest.size ());
112112 if (result <= 0 )
113113 break ;
114- const unsigned char *p = asn1.data ();
115- SCOPE (ECDSA_SIG, sig, d2i_ECDSA_SIG (nullptr , &p, long (asn1.size ())));
114+ auto sig = d2i<d2i_ECDSA_SIG, ECDSA_SIG_free>(asn1);
116115 const BIGNUM *r = nullptr , *s = nullptr ;
117116 ECDSA_SIG_get0 (sig.get (), &r, &s);
118117 auto r_len = size_t (BN_num_bytes (r));
0 commit comments