crypto

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FIPSKeyAlgorithmECCP521 = "ECC-P521"
	FIPSKeyAlgorithmRSA4096 = "RSA-4096"
	FIPSCipherAlgorithm     = "AES-256-GCM"
	FIPSHashingAlgorithm    = "SHA-512"
	FIPSMacAlgorithm        = "HMAC-SHA-512"
	FIPSSignatureAlgorithm  = "ECDSA"
)

FIPS 140-3 compliant algorithm constants.

Variables

This section is empty.

Functions

func ExtractAlgorithmName

func ExtractAlgorithmName(algorithm string) string

ExtractAlgorithmName extracts the base algorithm name from a full algorithm string. Examples:

  • "RSA-4096" -> "RSA"
  • "ECC P-521" -> "ECC"
  • "AES-256-GCM" -> "AES"
  • "SHA-512" -> "SHA"
  • "RSA" -> "RSA" (already clean)

func ExtractBitLength

func ExtractBitLength(algorithm string) int

ExtractBitLength extracts the bit length from an algorithm name. Examples:

  • "RSA-4096" -> 4096
  • "RSA-3072" -> 3072
  • "ECC P-521" -> 521
  • "ECC P-256" -> 256
  • "AES-256-GCM" -> 256
  • "SHA-512" -> 512

Returns 0 if no bit length can be extracted.

func GetAlgorithmDetails

func GetAlgorithmDetails(algorithm string) (name string, bits int)

GetAlgorithmDetails returns both name and bit length for an algorithm.

func ValidateFIPS140_3Compliance

func ValidateFIPS140_3Compliance(algo string) error

ValidateFIPS140_3Compliance checks if an algorithm is FIPS 140-3 compliant.

Types

type AlgorithmValidator

type AlgorithmValidator struct {
	// contains filtered or unexported fields
}

AlgorithmValidator validates cryptographic algorithms against a policy. It can be used to enforce FIPS 140-3 compliance or custom algorithm policies.

func NewAlgorithmValidator

func NewAlgorithmValidator(
	ciphers, hashing, mac, asymmetric, signature []string,
) AlgorithmValidator

NewAlgorithmValidator creates a new validator with the specified allowed algorithms.

func NewFIPSValidator

func NewFIPSValidator() AlgorithmValidator

NewFIPSValidator creates a new validator enforcing FIPS 140-3 standards.

func (AlgorithmValidator) ValidateAsymmetric

func (av AlgorithmValidator) ValidateAsymmetric(algo string) error

ValidateAsymmetric checks if an asymmetric algorithm is allowed.

Jump to

Keyboard shortcuts

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