| author | |
| committer | |
| log | 7f20c78c95d54e7fb0958693a9df2dee40dd99d6 |
| tree | f4160af44492dd8d30a30ca910c307ab0c52090e |
| parent | 4466f145d67b7e343309347b4d1f59f10a3590af |
3 files changed, 10 insertions(+), 20 deletions(-)
lib/std/crypto/25519/ed25519.zig+2-9| ... | @@ -229,15 +229,8 @@ pub const Ed25519 = struct { | ... | @@ -229,15 +229,8 @@ pub const Ed25519 = struct { |
| 229 | /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range, | 229 | /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range, |
| 230 | /// or SignatureVerificationError if the signature is invalid for the given message and key. | 230 | /// or SignatureVerificationError if the signature is invalid for the given message and key. |
| 231 | pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void { | 231 | pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void { |
| 232 | try sig.concatVerify(&.{msg}, public_key); | 232 | var st = try sig.verifier(public_key); |
| 233 | } | 233 | st.update(msg); |
| 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); | ||
| 241 | try st.verify(); | 234 | try st.verify(); |
| 242 | } | 235 | } |
| 243 | }; | 236 | }; |
lib/std/crypto/ecdsa.zig+2-9| ... | @@ -101,15 +101,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { | ... | @@ -101,15 +101,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { |
| 101 | /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range, | 101 | /// Return IdentityElement or NonCanonical if the public key or signature are not in the expected range, |
| 102 | /// or SignatureVerificationError if the signature is invalid for the given message and key. | 102 | /// or SignatureVerificationError if the signature is invalid for the given message and key. |
| 103 | pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void { | 103 | pub fn verify(sig: Signature, msg: []const u8, public_key: PublicKey) VerifyError!void { |
| 104 | try sig.concatVerify(&.{msg}, public_key); | 104 | var st = try sig.verifier(public_key); |
| 105 | } | 105 | st.update(msg); |
| 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); | ||
| 113 | try st.verify(); | 106 | try st.verify(); |
| 114 | } | 107 | } |
| 115 | 108 |
lib/std/crypto/tls/Client.zig+6-2| ... | @@ -1735,7 +1735,9 @@ const CertificatePublicKey = struct { | ... | @@ -1735,7 +1735,9 @@ const CertificatePublicKey = struct { |
| 1735 | const Ecdsa = SchemeEcdsa(comptime_scheme); | 1735 | const Ecdsa = SchemeEcdsa(comptime_scheme); |
| 1736 | const sig = try Ecdsa.Signature.fromDer(encoded_sig); | 1736 | const sig = try Ecdsa.Signature.fromDer(encoded_sig); |
| 1737 | const key = try Ecdsa.PublicKey.fromSec1(pub_key); | 1737 | 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(); | ||
| 1739 | }, | 1741 | }, |
| 1740 | inline .rsa_pkcs1_sha256, | 1742 | inline .rsa_pkcs1_sha256, |
| 1741 | .rsa_pkcs1_sha384, | 1743 | .rsa_pkcs1_sha384, |
| ... | @@ -1769,7 +1771,9 @@ const CertificatePublicKey = struct { | ... | @@ -1769,7 +1771,9 @@ const CertificatePublicKey = struct { |
| 1769 | const sig = Eddsa.Signature.fromBytes(encoded_sig[0..Eddsa.Signature.encoded_length].*); | 1771 | const sig = Eddsa.Signature.fromBytes(encoded_sig[0..Eddsa.Signature.encoded_length].*); |
| 1770 | if (pub_key.len != Eddsa.PublicKey.encoded_length) return error.InvalidEncoding; | 1772 | if (pub_key.len != Eddsa.PublicKey.encoded_length) return error.InvalidEncoding; |
| 1771 | const key = try Eddsa.PublicKey.fromBytes(pub_key[0..Eddsa.PublicKey.encoded_length].*); | 1773 | 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(); | ||
| 1773 | }, | 1777 | }, |
| 1774 | else => unreachable, | 1778 | else => unreachable, |
| 1775 | } | 1779 | } |