Skip to content

Commit

Permalink
Changed to use builtin copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Jul 25, 2024
1 parent 1821f85 commit 2a2e52c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/crypto/cipher/gcm/gcm.mpcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- go -*-
//
// Copyright (c) 2021-2023 Markku Rossi
// Copyright (c) 2021-2024 Markku Rossi
//
// All rights reserved.
//
Expand Down Expand Up @@ -31,7 +31,7 @@ func EncryptAES128(key [16]byte, nonce [NonceSize]byte,

var counter [aes.BlockSize]byte

counter = memcpy(counter, 0, nonce, 0)
copy(counter, nonce)
counter = incr(counter)

e0 := byteToUint128(aes.Block128(key, counter))
Expand Down Expand Up @@ -104,7 +104,7 @@ func DecryptAES128(key [16]byte, nonce [NonceSize]byte,

var counter [aes.BlockSize]byte

counter = memcpy(counter, 0, nonce, 0)
copy(counter, nonce)
counter = incr(counter)

e0 := byteToUint128(aes.Block128(key, counter))
Expand Down Expand Up @@ -229,10 +229,3 @@ func multGF2Pow128(x, y uint128) uint128 {
}
return z
}

func memcpy(dst []byte, dstOfs int, src []byte, srcOfs int) []byte {
for i := 0; srcOfs+i < len(src) && dstOfs+i < len(dst); i++ {
dst[dstOfs+i] = src[srcOfs+i]
}
return dst
}

0 comments on commit 2a2e52c

Please sign in to comment.