authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-11-01 16:29:35-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-11-07 20:25:26-05:00
log7f20c78c95d54e7fb0958693a9df2dee40dd99d6
treef4160af44492dd8d30a30ca910c307ab0c52090e
parent4466f145d67b7e343309347b4d1f59f10a3590af

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


3 files changed, 10 insertions(+), 20 deletions(-)

lib/std/crypto/25519/ed25519.zig+2-9
......@@ -229,15 +229,8 @@ pub const Ed25519 = struct {
229229 /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
230230 /// or SignatureVerificationError if the signature is invalid for the given message and key.
231231 pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void {
232 try sig.concatVerify(&.{msg}, public_key);
233 }
234
235 /// Verify the signature against a concatenated message and public key.
236 /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
237 /// or SignatureVerificationError if the signature is invalid for the given message and key.
238 pub fn concatVerify(sig: Signature, msg: []const []const u8, public_key: PublicKey) VerifyError!void {
239 var st = try Verifier.init(sig, public_key);
240 for (msg) |part| st.update(part);
232 var st = try sig.verifier(public_key);
233 st.update(msg);
241234 try st.verify();
242235 }
243236 };
lib/std/crypto/ecdsa.zig+2-9
......@@ -101,15 +101,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
101101 /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
102102 /// or SignatureVerificationError if the signature is invalid for the given message and key.
103103 pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void {
104 try sig.concatVerify(&.{msg}, public_key);
105 }
106
107 /// Verify the signature against a concatenated message and public key.
108 /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range,
109 /// or SignatureVerificationError if the signature is invalid for the given message and key.
110 pub fn concatVerify(sig: Signature, msg: []const []const u8, public_key: PublicKey) VerifyError!void {
111 var st = try Verifier.init(sig, public_key);
112 for (msg) |part| st.update(part);
104 var st = try sig.verifier(public_key);
105 st.update(msg);
113106 try st.verify();
114107 }
115108
lib/std/crypto/tls/Client.zig+6-2
......@@ -1735,7 +1735,9 @@ const CertificatePublicKey = struct {
17351735 const Ecdsa = SchemeEcdsa(comptime_scheme);
17361736 const sig = try Ecdsa.Signature.fromDer(encoded_sig);
17371737 const key = try Ecdsa.PublicKey.fromSec1(pub_key);
1738 try sig.concatVerify(msg, key);
1738 var ver = try sig.verifier(key);
1739 for (msg) |part| ver.update(part);
1740 try ver.verify();
17391741 },
17401742 inline .rsa_pkcs1_sha256,
17411743 .rsa_pkcs1_sha384,
......@@ -1769,7 +1771,9 @@ const CertificatePublicKey = struct {
17691771 const sig = Eddsa.Signature.fromBytes(encoded_sig[0..Eddsa.Signature.encoded_length].*);
17701772 if (pub_key.len != Eddsa.PublicKey.encoded_length) return error.InvalidEncoding;
17711773 const key = try Eddsa.PublicKey.fromBytes(pub_key[0..Eddsa.PublicKey.encoded_length].*);
1772 try sig.concatVerify(msg, key);
1774 var ver = try sig.verifier(key);
1775 for (msg) |part| ver.update(part);
1776 try ver.verify();
17731777 },
17741778 else => unreachable,
17751779 }