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