mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
core/crypto: Switch to using ensure
This commit is contained in:
@@ -28,9 +28,7 @@ fe_from_bytes :: #force_inline proc "contextless" (
|
||||
// makes implementing the actual MAC block processing considerably
|
||||
// neater.
|
||||
|
||||
if len(arg1) != 16 {
|
||||
panic_contextless("poly1305: invalid field element size")
|
||||
}
|
||||
ensure_contextless(len(arg1) == 16, "poly1305: invalid field element size")
|
||||
|
||||
// While it may be unwise to do deserialization here on our
|
||||
// own when fiat-crypto provides equivalent functionality,
|
||||
|
||||
@@ -94,9 +94,8 @@ fe_from_bytes_wide :: proc "contextless" (
|
||||
@(private)
|
||||
_fe_from_bytes_short :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element, arg1: []byte) {
|
||||
// INVARIANT: len(arg1) < 32.
|
||||
if len(arg1) >= 32 {
|
||||
panic_contextless("edwards25519: oversized short scalar")
|
||||
}
|
||||
ensure_contextless(len(arg1) < 32, "edwards25519: oversized short scalar")
|
||||
|
||||
tmp: [32]byte
|
||||
copy(tmp[:], arg1)
|
||||
|
||||
@@ -105,9 +104,7 @@ _fe_from_bytes_short :: proc "contextless" (out1: ^Montgomery_Domain_Field_Eleme
|
||||
}
|
||||
|
||||
fe_to_bytes :: proc "contextless" (out1: []byte, arg1: ^Montgomery_Domain_Field_Element) {
|
||||
if len(out1) != 32 {
|
||||
panic_contextless("edwards25519: oversized scalar output buffer")
|
||||
}
|
||||
ensure_contextless(len(out1) == 32, "edwards25519: oversized scalar output buffer")
|
||||
|
||||
tmp: Non_Montgomery_Domain_Field_Element
|
||||
fe_from_montgomery(&tmp, arg1)
|
||||
|
||||
Reference in New Issue
Block a user