@@ -265,11 +265,11 @@ es256_from_coords(const std::string &x_str, const std::string &y_str) {
265265 if (!Q_point.get ()) {
266266 throw UnsupportedKeyException (" Unable to allocate new EC point" );
267267 }
268-
268+
269269 if (!EC_POINT_set_affine_coordinates (ec_group.get (), Q_point.get (), x_bignum.get (), y_bignum.get (), NULL )) {
270270 throw UnsupportedKeyException (" Invalid elliptic curve point in key" );
271271 }
272-
272+
273273 size_t out_len = EC_POINT_point2buf (ec_group.get (), Q_point.get (),POINT_CONVERSION_UNCOMPRESSED,&buf,NULL );
274274 if (out_len == 0 ) {
275275 throw UnsupportedKeyException (" Failed to convert EC point to octet base buffer" );
@@ -282,19 +282,19 @@ es256_from_coords(const std::string &x_str, const std::string &y_str) {
282282 || (params = OSSL_PARAM_BLD_to_param (param_build.get ())) == NULL ) {
283283 throw UnsupportedKeyException (" Failed to build EC public key parameters" );
284284 }
285-
285+
286286 EVP_PKEY *pkey = NULL ;
287287 std::unique_ptr<EVP_PKEY_CTX, decltype (&EVP_PKEY_CTX_free)> ec_ctx (EVP_PKEY_CTX_new_from_name (NULL , " EC" , NULL ), EVP_PKEY_CTX_free);
288288 if (!ec_ctx.get ()) {
289289 throw UnsupportedKeyException (" Failed to set EC PKEY context" );
290290 }
291-
292- if (EVP_PKEY_fromdata_init (ec_ctx.get ()) <= 0
293- || EVP_PKEY_fromdata (ec_ctx.get (),&pkey,EVP_PKEY_PUBLIC_KEY,params) <= 0
294- || pkey == NULL ) {
295- throw UnsupportedKeyException (" Failed to set the EC public key" );
296- }
297-
291+
292+ if (EVP_PKEY_fromdata_init (ec_ctx.get ()) <= 0
293+ || EVP_PKEY_fromdata (ec_ctx.get (),&pkey,EVP_PKEY_PUBLIC_KEY,params) <= 0
294+ || pkey == NULL ) {
295+ throw UnsupportedKeyException (" Failed to set the EC public key" );
296+ }
297+
298298 if (PEM_write_bio_PUBKEY (pubkey_bio.get (), pkey) == 0 ) {
299299 throw UnsupportedKeyException (" Failed to serialize EC public key" );
300300 }
@@ -329,7 +329,7 @@ es256_from_coords(const std::string &x_str, const std::string &y_str) {
329329 throw UnsupportedKeyException (" Failed to serialize EC public key" );
330330 }
331331#endif
332-
332+
333333 char *mem_data;
334334 size_t mem_len = BIO_get_mem_data (pubkey_bio.get (), &mem_data);
335335 std::string result = std::string (mem_data, mem_len);
@@ -348,30 +348,30 @@ rs256_from_coords(const std::string &e_str, const std::string &n_str) {
348348#if OPENSSL_VERSION_NUMBER >= 0x30000000L
349349 OSSL_PARAM *params;
350350 std::unique_ptr<EVP_PKEY_CTX, decltype (&EVP_PKEY_CTX_free)> rsa_ctx (EVP_PKEY_CTX_new_from_name (NULL , " RSA" , NULL ), EVP_PKEY_CTX_free);
351- if (!rsa_ctx.get ()) {
352- throw UnsupportedKeyException (" Failed to set RSA PKEY context" );
353- }
354-
351+ if (!rsa_ctx.get ()) {
352+ throw UnsupportedKeyException (" Failed to set RSA PKEY context" );
353+ }
354+
355355 std::unique_ptr<OSSL_PARAM_BLD, decltype (&OSSL_PARAM_BLD_free)> param_build (OSSL_PARAM_BLD_new (), OSSL_PARAM_BLD_free);
356- if (!param_build.get ()
356+ if (!param_build.get ()
357357 || !OSSL_PARAM_BLD_push_BN_pad (param_build.get ()," e" ,e_bignum.get (),BN_num_bytes (e_bignum.get ()))
358358 || !OSSL_PARAM_BLD_push_BN_pad (param_build.get ()," n" ,n_bignum.get (),BN_num_bytes (n_bignum.get ()))
359359 || (params = OSSL_PARAM_BLD_to_param (param_build.get ())) == NULL ) {
360360 throw UnsupportedKeyException (" Failed to build RSA public key parameters" );
361361 }
362-
362+
363363 EVP_PKEY *pkey = NULL ;
364- if (EVP_PKEY_fromdata_init (rsa_ctx.get ()) <= 0
365- || EVP_PKEY_fromdata (rsa_ctx.get (),&pkey,EVP_PKEY_PUBLIC_KEY,params) <= 0
366- || pkey == NULL ) {
367- throw UnsupportedKeyException (" Failed to set the RSA public key" );
368- }
369-
364+ if (EVP_PKEY_fromdata_init (rsa_ctx.get ()) <= 0
365+ || EVP_PKEY_fromdata (rsa_ctx.get (),&pkey,EVP_PKEY_PUBLIC_KEY,params) <= 0
366+ || pkey == NULL ) {
367+ throw UnsupportedKeyException (" Failed to set the RSA public key" );
368+ }
369+
370370 if (PEM_write_bio_PUBKEY (pubkey_bio.get (), pkey) == 0 ) {
371371 throw UnsupportedKeyException (" Failed to serialize RSA public key" );
372372 }
373373 EVP_PKEY_free (pkey);
374- OSSL_PARAM_free (params);
374+ OSSL_PARAM_free (params);
375375#else
376376 std::unique_ptr<RSA, decltype (&RSA_free)> rsa (RSA_new (), RSA_free);
377377 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
@@ -385,7 +385,7 @@ rs256_from_coords(const std::string &e_str, const std::string &n_str) {
385385 if (EVP_PKEY_set1_RSA (pkey.get (), rsa.get ()) != 1 ) {
386386 throw UnsupportedKeyException (" Failed to set the public key" );
387387 }
388-
388+
389389 if (PEM_write_bio_PUBKEY (pubkey_bio.get (), pkey.get ()) == 0 ) {
390390 throw UnsupportedKeyException (" Failed to serialize RSA public key" );
391391 }
@@ -616,7 +616,7 @@ scitokens::Validator::store_public_ec_key(const std::string &issuer, const std::
616616
617617#if OPENSSL_VERSION_NUMBER >= 0x30000000L
618618 std::unique_ptr<EVP_PKEY, decltype (&EVP_PKEY_free)> pkey (PEM_read_bio_PUBKEY (pubkey_bio.get (),nullptr ,nullptr ,nullptr ), EVP_PKEY_free);
619- if (!pkey.get ()) {return false ;}
619+ if (!pkey.get ()) {return false ;}
620620
621621 std::unique_ptr<EC_GROUP, decltype (&EC_GROUP_free)> ec_group (EC_GROUP_new_by_curve_name (EC_NAME),EC_GROUP_free);
622622 if (!ec_group.get ()) {
@@ -627,7 +627,7 @@ scitokens::Validator::store_public_ec_key(const std::string &issuer, const std::
627627 if (!Q_point.get ()) {
628628 throw UnsupportedKeyException (" Unable to get OpenSSL EC point" );
629629 }
630-
630+
631631 if (!EC_POINT_get_affine_coordinates (ec_group.get (), Q_point.get (), x_bignum.get (), y_bignum.get (), NULL )) {
632632 throw UnsupportedKeyException (" Unable to get OpenSSL affine coordinates" );
633633 }
0 commit comments