@@ -20,6 +20,12 @@ using AutoEVP_PKEY_CTX = std::unique_ptr<EVP_PKEY_CTX, Deleter<EVP_PKEY_CTX_free
2020using AutoEVP_MD_CTX = std::unique_ptr<EVP_MD_CTX , Deleter<EVP_MD_CTX_free>>;
2121using AutoBIO = std::unique_ptr<BIO , Deleter<BIO_free>>;
2222
23+ std::string_view keyNamePart (std::string_view s)
24+ {
25+ auto colon = s.find (' :' );
26+ return colon == std::string_view::npos ? std::string_view{} : s.substr (0 , colon);
27+ }
28+
2329/* *
2430 * Parse a colon-separated string where the second part is Base64-encoded.
2531 *
@@ -487,8 +493,7 @@ std::unique_ptr<SecretKey> SecretKey::parse(std::string_view s)
487493 throw Error (" secret key is not valid" );
488494
489495 } catch (Error & e) {
490- // Don't show the entire key for security.
491- e.addTrace ({}, " while decoding key '%s…'" , s.substr (0 , 32 ));
496+ e.addTrace ({}, " while decoding key '%s'" , keyNamePart (s));
492497 throw ;
493498 }
494499}
@@ -526,8 +531,7 @@ std::unique_ptr<PublicKey> PublicKey::parse(std::string_view s)
526531 } else
527532 throw Error (" public key is not valid" );
528533 } catch (Error & e) {
529- // Don't show the entire key for security.
530- e.addTrace ({}, " while decoding key '%s'" , s);
534+ e.addTrace ({}, " while decoding key '%s'" , keyNamePart (s));
531535 throw ;
532536 }
533537}
0 commit comments