Skip to content

Commit

Permalink
rename load_privkey_from_string to privkey_from_string to align consi…
Browse files Browse the repository at this point in the history
…stenly with pubkey_from_bytes name
  • Loading branch information
blackshirt committed Jan 15, 2025
1 parent b7db996 commit 14dd9af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vlib/crypto/ecdsa/util.v
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ fn C.BIO_write(b &C.BIO, buf &u8, length int) int
// EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
fn C.PEM_read_bio_PrivateKey(bp &C.BIO, x &&C.EVP_PKEY, cb int, u &voidptr) &C.EVP_PKEY

// load_privkey_from_string loads PrivateKey from valid PEM-formatted string in s.
// privkey_from_string loads PrivateKey from valid PEM-formatted string in s.
// Underlying wrapper support for old secg and pkcs8 private key format, but this not heavily tested.
// This routine also does not handling for pkcs8 EncryptedPrivateKeyInfo format, the callback was not handled.
pub fn load_privkey_from_string(s string) !PrivateKey {
pub fn privkey_from_string(s string) !PrivateKey {
if s.len == 0 {
return error('null string was not allowed')
}
Expand Down
4 changes: 2 additions & 2 deletions vlib/crypto/ecdsa/util_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn test_for_pubkey_bytes() ! {
// -----END EC PRIVATE KEY-----
// ```
fn test_load_privkey_from_string_sign_and_verify() ! {
pvkey := load_privkey_from_string(privatekey_sample)!
pvkey := privkey_from_string(privatekey_sample)!
expected_pvkey_bytes := '30ce3da288965ac6093f0ba9a9a15b2476bea3eda925e1b3c1f094674f52795cd6cb3cafe235dfc15bec542448ffa715'
assert pvkey.seed()!.hex() == expected_pvkey_bytes

Expand All @@ -108,7 +108,7 @@ fn test_load_privkey_from_string_with_unsupported_curve() ! {
MFwCAQEEGDHV+WhJL2UjUhgMLh52k0RJjRebtu4HvqAHBgUrgQQAH6E0AzIABFyF
UHhnmmVRraSwrVkPdYIeXhH/Ob4+8OLcwrQBMv4RXsD1GVFsgkvEYDTEb/vnMA==
-----END EC PRIVATE KEY-----'
_ := load_privkey_from_string(key) or {
_ := privkey_from_string(key) or {
assert err == error('Unsupported group')
return
}
Expand Down

0 comments on commit 14dd9af

Please sign in to comment.