authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2024-04-20 15:23:15+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-20 16:27:56-07:00
logd8764ec770a60109cc29e410e821af97122218d3
treeb2ae6c17baa1b2d71c529e05a9e7638406b38dcb
parent7789e87230778b93fb9a584722dcc6d8a5b2030f

Rename der_encoded_max_length to der_encoded_length_max

The `length_min`/`length_max` convention is used everywhere else in `std.crypto.*` so be consistent.

1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/crypto/ecdsa.zig+4-4
...@@ -83,7 +83,7 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {...@@ -83,7 +83,7 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
83 /// Length (in bytes) of a raw signature.83 /// Length (in bytes) of a raw signature.
84 pub const encoded_length = Curve.scalar.encoded_length * 2;84 pub const encoded_length = Curve.scalar.encoded_length * 2;
85 /// Maximum length (in bytes) of a DER-encoded signature.85 /// Maximum length (in bytes) of a DER-encoded signature.
86 pub const der_encoded_max_length = encoded_length + 2 + 2 * 3;86 pub const der_encoded_length_max = encoded_length + 2 + 2 * 3;
8787
88 /// The R component of an ECDSA signature.88 /// The R component of an ECDSA signature.
89 r: Curve.scalar.CompressedScalar,89 r: Curve.scalar.CompressedScalar,
...@@ -122,9 +122,9 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {...@@ -122,9 +122,9 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
122 }122 }
123123
124 /// Encode the signature using the DER format.124 /// Encode the signature using the DER format.
125 /// The maximum length of the DER encoding is der_encoded_max_length.125 /// The maximum length of the DER encoding is der_encoded_length_max.
126 /// The function returns a slice, that can be shorter than der_encoded_max_length.126 /// The function returns a slice, that can be shorter than der_encoded_length_max.
127 pub fn toDer(self: Signature, buf: *[der_encoded_max_length]u8) []u8 {127 pub fn toDer(self: Signature, buf: *[der_encoded_length_max]u8) []u8 {
128 var fb = io.fixedBufferStream(buf);128 var fb = io.fixedBufferStream(buf);
129 const w = fb.writer();129 const w = fb.writer();
130 const r_len = @as(u8, @intCast(self.r.len + (self.r[0] >> 7)));130 const r_len = @as(u8, @intCast(self.r.len + (self.r[0] >> 7)));