core/crypto: Switch to using ensure
This commit is contained in:
1 parent
dc94452fb9
commit
2f301e46dc
36 files changed
+188
-363
No files matched your search
@@ -60,7 +60,7 @@ init :: proc(ctx: ^Context) {
|
||||
|
||||
// update adds more data to the Context.
|
||||
update :: proc(ctx: ^Context, data: []byte) {
|
||||
assert(ctx.is_initialized)
|
||||
ensure(ctx.is_initialized)
|
||||
|
||||
for i := 0; i < len(data); i += 1 {
|
||||
ctx.data[ctx.datalen] = data[i]
|
||||
@@ -79,11 +79,8 @@ update :: proc(ctx: ^Context, data: []byte) {
|
||||
// Iff finalize_clone is set, final will work on a copy of the Context,
|
||||
// which is useful for for calculating rolling digests.
|
||||
final :: proc(ctx: ^Context, hash: []byte, finalize_clone: bool = false) {
|
||||
assert(ctx.is_initialized)
|
||||
|
||||
if len(hash) < DIGEST_SIZE {
|
||||
panic("crypto/sha1: invalid destination digest size")
|
||||
}
|
||||
ensure(ctx.is_initialized)
|
||||
ensure(len(hash) >= DIGEST_SIZE, "crypto/sha1: invalid destination digest size")
|
||||
|
||||
ctx := ctx
|
||||
if finalize_clone {
|
||||
|
||||
Reference in new issue
Block a user