aes

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////////////////

Index

Constants

View Source
const (
	// All instances of this class use a 12 byte IV and 16 byte tag
	AES_GCM_IV_SIZE  = 12
	AES_GCM_TAG_SIZE = 16
)

Variables

This section is empty.

Functions

func ValidateAesKeySize

func ValidateAesKeySize(sizeInBytes uint32) error

ValidateAesKeySize checks if the given key size is a valid AES key size.

Types

type AesGcm

type AesGcm struct {
	Key []byte
}

AesGcm is an implementation of Aead interface.

func NewAesGcm

func NewAesGcm(key []byte) (*AesGcm, error)

NewAesGcm returns an AesGcm instance. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func (*AesGcm) Decrypt

func (a *AesGcm) Decrypt(ct []byte, aad []byte) ([]byte, error)

Decrypt decrypts {@code ct} with {@code aad} as the additionalauthenticated data.

func (*AesGcm) Encrypt

func (a *AesGcm) Encrypt(pt []byte, aad []byte) ([]byte, error)

Encrypt encrypts {@code pt} with {@code aad} as additional authenticated data. The resulting ciphertext consists of two parts: (1) the IV used for encryption and (2) the actual ciphertext.

Note: AES-GCM implementation of crypto library always returns ciphertext with 128-bit tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL