// Copyright 2024 Sun Yimin. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. //go:build purego || !s390x package cipher import ( _cipher "crypto/cipher" ) // A proxy of Golang cipher gcm mode. // NewGCM returns the given 128-bit, block cipher wrapped in Galois Counter Mode // with the standard nonce length. // // In general, the GHASH operation performed by this implementation of GCM is not constant-time. // An exception is when the underlying Block was created by aes.NewCipher // on systems with hardware support for AES. See the crypto/aes package documentation for details. func NewGCM(cipher _cipher.Block) (_cipher.AEAD, error) { return _cipher.NewGCM(cipher) } // NewGCMWithNonceSize returns the given 128-bit, block cipher wrapped in Galois // Counter Mode, which accepts nonces of the given length. The length must not // be zero. // // Only use this function if you require compatibility with an existing // cryptosystem that uses non-standard nonce lengths. All other users should use // NewGCM, which is faster and more resistant to misuse. func NewGCMWithNonceSize(cipher _cipher.Block, size int) (_cipher.AEAD, error) { return _cipher.NewGCMWithNonceSize(cipher, size) } // NewGCMWithTagSize returns the given 128-bit, block cipher wrapped in Galois // Counter Mode, which generates tags with the given length. // // Tag sizes between 12 and 16 bytes are allowed. // // Only use this function if you require compatibility with an existing // cryptosystem that uses non-standard tag lengths. All other users should use // NewGCM, which is more resistant to misuse. func NewGCMWithTagSize(cipher _cipher.Block, tagSize int) (_cipher.AEAD, error) { return _cipher.NewGCMWithTagSize(cipher, tagSize) }