std.crypto: delete new functions that are only used once

This commit is contained in:
Jacob Young 2024-11-01 16:29:35 -04:00
parent 4466f145d6
commit 7f20c78c95
3 changed files with 10 additions and 20 deletions

View File

@ -229,15 +229,8 @@ pub const Ed25519 = struct {
/// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
/// or SignatureVerificationError if the signature is invalid for the given message and key.
pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void {
try sig.concatVerify(&.{msg}, public_key);
}
/// Verify the signature against a concatenated message and public key.
/// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
/// or SignatureVerificationError if the signature is invalid for the given message and key.
pub fn concatVerify(sig: Signature, msg: []const []const u8, public_key: PublicKey) VerifyError!void {
var st = try Verifier.init(sig, public_key);
for (msg) |part| st.update(part);
var st = try sig.verifier(public_key);
st.update(msg);
try st.verify();
}
};

View File

@ -101,15 +101,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
/// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
/// or SignatureVerificationError if the signature is invalid for the given message and key.
pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void {
try sig.concatVerify(&.{msg}, public_key);
}
/// Verify the signature against a concatenated message and public key.
/// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
/// or SignatureVerificationError if the signature is invalid for the given message and key.
pub fn concatVerify(sig: Signature, msg: []const []const u8, public_key: PublicKey) VerifyError!void {
var st = try Verifier.init(sig, public_key);
for (msg) |part| st.update(part);
var st = try sig.verifier(public_key);
st.update(msg);
try st.verify();
}

View File

@ -1735,7 +1735,9 @@ const CertificatePublicKey = struct {
const Ecdsa = SchemeEcdsa(comptime_scheme);
const sig = try Ecdsa.Signature.fromDer(encoded_sig);
const key = try Ecdsa.PublicKey.fromSec1(pub_key);
try sig.concatVerify(msg, key);
var ver = try sig.verifier(key);
for (msg) |part| ver.update(part);
try ver.verify();
},
inline .rsa_pkcs1_sha256,
.rsa_pkcs1_sha384,
@ -1769,7 +1771,9 @@ const CertificatePublicKey = struct {
const sig = Eddsa.Signature.fromBytes(encoded_sig[0..Eddsa.Signature.encoded_length].*);
if (pub_key.len != Eddsa.PublicKey.encoded_length) return error.InvalidEncoding;
const key = try Eddsa.PublicKey.fromBytes(pub_key[0..Eddsa.PublicKey.encoded_length].*);
try sig.concatVerify(msg, key);
var ver = try sig.verifier(key);
for (msg) |part| ver.update(part);
try ver.verify();
},
else => unreachable,
}