From 513b786694d99a0dfeff7efbbeecbf4b8f6e823a Mon Sep 17 00:00:00 2001 From: Emman Date: Wed, 31 Mar 2021 12:01:22 +0800 Subject: [PATCH] MAGIC - add license --- cipher/ccm.go | 4 ++-- cipher/ccm_test.go | 1 + cipher/xor_amd64.go | 4 ++++ cipher/xor_amd64.s | 4 ++++ cipher/xor_generic.go | 6 +++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cipher/ccm.go b/cipher/ccm.go index bd39acb..b3f9b2d 100644 --- a/cipher/ccm.go +++ b/cipher/ccm.go @@ -127,8 +127,8 @@ func (c *ccm) auth(nonce, plaintext, additionalData []byte, tagMask *[ccmBlockSi if len(additionalData) > 0 { out[0] = 1 << 6 // 64*Adata } - out[0] |= byte(c.tagSize-2) << 2 - out[0] |= byte(14 - c.nonceSize) + out[0] |= byte(c.tagSize-2) << 2 // M' = ((tagSize - 2) / 2)*8 + out[0] |= byte(14 - c.nonceSize) // L' binary.BigEndian.PutUint64(out[ccmBlockSize-8:], uint64(len(plaintext))) copy(out[1:], nonce) c.cipher.Encrypt(out[:], out[:]) diff --git a/cipher/ccm_test.go b/cipher/ccm_test.go index b0febb2..ddb2d46 100644 --- a/cipher/ccm_test.go +++ b/cipher/ccm_test.go @@ -6,6 +6,7 @@ import ( "testing" ) +// https://tools.ietf.org/html/rfc3610, 8. Test Vectors var aesCCMTests = []struct { key, nonce, plaintext, ad, result string tagSize int diff --git a/cipher/xor_amd64.go b/cipher/xor_amd64.go index 4db7b3f..07e4d0f 100644 --- a/cipher/xor_amd64.go +++ b/cipher/xor_amd64.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package cipher // XorBytes xors the bytes in a and b. The destination should have enough diff --git a/cipher/xor_amd64.s b/cipher/xor_amd64.s index dfd40b4..8085d28 100644 --- a/cipher/xor_amd64.s +++ b/cipher/xor_amd64.s @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + #include "textflag.h" // func xorBytesSSE2(dst, a, b *byte, n int) diff --git a/cipher/xor_generic.go b/cipher/xor_generic.go index cac5843..b7451ea 100644 --- a/cipher/xor_generic.go +++ b/cipher/xor_generic.go @@ -1,3 +1,7 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build !amd64 package cipher @@ -84,4 +88,4 @@ func XorWords(dst, a, b []byte) { } else { safeXORBytes(dst, a, b, len(b)) } -} \ No newline at end of file +}