From 2f2a92866b1e40ab793d4f87a44329421f7f6009 Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Sun, 25 Feb 2024 17:38:30 +0900 Subject: [PATCH] core/crypto/hmac: Add a clone method --- core/crypto/hmac/hmac.odin | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/crypto/hmac/hmac.odin b/core/crypto/hmac/hmac.odin index f720d2181..cd389fe6f 100644 --- a/core/crypto/hmac/hmac.odin +++ b/core/crypto/hmac/hmac.odin @@ -78,6 +78,18 @@ final :: proc(ctx: ^Context, dst: []byte) { hash.final(&ctx._o_hash, dst) } +// clone clones the Context other into ctx. +clone :: proc(ctx, other: ^Context) { + if ctx == other { + return + } + + hash.clone(&ctx._o_hash, &other._o_hash) + hash.clone(&ctx._i_hash, &other._i_hash) + ctx._tag_sz = other._tag_sz + ctx._is_initialized = other._is_initialized +} + // reset sanitizes the Context. The Context must be re-initialized to // be used again. reset :: proc(ctx: ^Context) {