aesgcm

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

README

pki/aesgcm

Import path: github.com/InsideGallery/core/pki/aesgcm

aesgcm is the preferred AES-GCM import path. It re-exports the legacy pki/aes implementation with names that avoid a local collision with Go's standard crypto/aes package.

Main API

  • Cipher is an alias for the legacy AES-GCM cipher type.
  • New(size) creates a cipher with a random key.
  • KeySize16, KeySize24, and KeySize32 are supported key sizes in bytes.
  • ErrInvalidKeySize reports unsupported key sizes.
  • Cipher.Encrypt, Cipher.Decrypt, Cipher.Kind, Cipher.ToBinary, and Cipher.FromBinary are inherited from pki/aes.

Usage

package example

import "github.com/InsideGallery/core/pki/aesgcm"

func roundTrip(plaintext []byte) ([]byte, error) {
	cipher, err := aesgcm.New(aesgcm.KeySize32)
	if err != nil {
		return nil, err
	}

	ciphertext, err := cipher.Encrypt(plaintext)
	if err != nil {
		return nil, err
	}

	return cipher.Decrypt(ciphertext)
}

Security and Compatibility Notes

Encryption uses AES-GCM with a random nonce, prefixes that nonce to the ciphertext, and hex-encodes the combined bytes. The implementation does not use additional authenticated data. github.com/InsideGallery/core/pki/aes remains available for existing consumers, but new code should import this package.

Documentation

Overview

Package aesgcm provides AES-GCM cipher helpers without colliding with crypto/aes.

New code should import this package instead of the legacy pki/aes path:

import "github.com/InsideGallery/core/pki/aesgcm"

Compatibility: github.com/InsideGallery/core/pki/aes remains available for existing consumers. Prefer New and KeySize constants from aesgcm so AES-GCM usage has an algorithm-specific import path.

Index

Constants

View Source
const (
	// KeySize32 is the 256-bit AES key size in bytes.
	KeySize32 = legacy.AES32
	// KeySize24 is the 192-bit AES key size in bytes.
	KeySize24 = legacy.AES24
	// KeySize16 is the 128-bit AES key size in bytes.
	KeySize16 = legacy.AES16
)

Variables

View Source
var ErrInvalidKeySize = legacy.ErrInvalidAESSize

ErrInvalidKeySize reports an unsupported AES key size.

Functions

This section is empty.

Types

type Cipher

type Cipher = legacy.AES

Cipher encrypts and decrypts data with AES-GCM.

func New

func New(size int) (*Cipher, error)

New returns an AES-GCM cipher with a randomly generated key.

Jump to

Keyboard shortcuts

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