hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit e191f7c268b44ea88aefd993d7536bde4ca8ba2c
parent 8079a00d631c45ee149d9236f73af4dd4e835422
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Mon, 15 Jan 2024 15:45:39 +0100

crypto::rsa: add pubkey_nbitlen

used to check if signatures are within the public modulus

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mcrypto/rsa/keys.ha | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/crypto/rsa/keys.ha b/crypto/rsa/keys.ha @@ -87,6 +87,12 @@ export fn pubkey_init(pubkey: []u8, x: pubparams) (size | error) = { return s; }; +// Returns the length of the modulus 'n' of given public key. +export fn pubkey_nbitlen(pubkey: []u8) size = { + let p = pubkey_params(pubkey); + return bitlen(p.n); +}; + // Returns the length the public key would require in its encoded form. fn pubkey_len(n: []u8, e: []u8) size = 1z + 2 + len(n) + 2 + len(e);