From 14dd9afc9d2fe09f9344f77696cb9c8cb8766adc Mon Sep 17 00:00:00 2001 From: blackshirt Date: Wed, 15 Jan 2025 01:54:54 +0000 Subject: [PATCH] rename load_privkey_from_string to privkey_from_string to align consistenly with pubkey_from_bytes name --- vlib/crypto/ecdsa/util.v | 4 ++-- vlib/crypto/ecdsa/util_test.v | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/crypto/ecdsa/util.v b/vlib/crypto/ecdsa/util.v index 63979cddc2867d..a73a948ee86201 100644 --- a/vlib/crypto/ecdsa/util.v +++ b/vlib/crypto/ecdsa/util.v @@ -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') } diff --git a/vlib/crypto/ecdsa/util_test.v b/vlib/crypto/ecdsa/util_test.v index 8b7c4218fada3f..aaa9ebb6ec0960 100644 --- a/vlib/crypto/ecdsa/util_test.v +++ b/vlib/crypto/ecdsa/util_test.v @@ -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 @@ -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 }