Commit 7f20c78c95

Jacob Young <jacobly0@users.noreply.github.com>
2024-11-01 21:29:35
std.crypto: delete new functions that are only used once
1 parent 4466f14
Changed files (3)
lib
std
lib/std/crypto/25519/ed25519.zig
@@ -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();
         }
     };
lib/std/crypto/tls/Client.zig
@@ -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,
         }
lib/std/crypto/ecdsa.zig
@@ -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();
             }