Versions in this module Expand all Collapse all v0 v0.1.0 Feb 13, 2023 Changes in this version + const ErrArmorPGPKeyFailureCode + const ErrDecodeFailureCode + const ErrDecryptFailureCode + const ErrEncodeFailureCode + const ErrEncryptFailureCode + const ErrExtractPublicKeyFailureCode + const ErrGenerateCertificateFailureCode + const ErrGenerateCipherFailureCode + const ErrGenerateGCMFailureCode + const ErrGenerateIVFailureCode + const ErrGenerateNonceFailureCode + const ErrGeneratePGPKeyFailureCode + const ErrGeneratePrivateKeyFailureCode + const ErrGenerateRandomKeyFailureCode + const ErrGetPGPKeyFailureCode + const ErrInvalidCertificateCode + const ErrInvalidJWTTokenClaimsCode + const ErrInvalidJWTTokenSignatureAlgorithmCode + const ErrInvalidSignatureCode + const ErrLoadCertificateFailureCode + const ErrLoadPGPKeyFailureCode + const ErrLockPGPKeyFailureCode + const ErrParseCertificateFailureCode + const ErrParseJWTTokenFailureCode + const ErrReadFileFailureCode + const ErrSignDataFailureCode + const ErrSignJWTTokenFailureCode + const ErrUnlockPGPKeyFailureCode + func DecodePEMBlockFromFile(ctx context.Context, file string) (*pem.Block, error) + func DecryptPEMBlock(ctx context.Context, b *pem.Block, password []byte) ([]byte, error) + func DecryptString(ctx context.Context, ciphertext, key string) (string, error) + func EncryptPEMBlock(ctx context.Context, rand io.Reader, blockType string, data, password []byte, ...) (*pem.Block, error) + func EncryptString(ctx context.Context, plaintext, key string) (string, error) + func GeneratePassword(passwordLength, minSpecialChar, minNum, minUpperCase int) string + func IsEncryptedPEMBlock(b *pem.Block) bool + func NewSelfSignedCertificateKeyPair(ctx context.Context, template *x509.Certificate, keyBits int) ([]byte, []byte, error) + func ParsePEMCertificateBytes(ctx context.Context, contents []byte) ([]*x509.Certificate, error) + func ParsePEMCertificateFile(ctx context.Context, file string) ([]*x509.Certificate, error) + func ParsePEMPrivateKeyBytes(ctx context.Context, contents []byte, password []byte) (*rsa.PrivateKey, error) + func ParsePEMPrivateKeyFile(ctx context.Context, file string, password []byte) (*rsa.PrivateKey, error) + func ParsePublicKeyFromCertificate(ctx context.Context, cert *x509.Certificate) (*rsa.PublicKey, error) + func Sign(ctx context.Context, contents []byte, privateKey *rsa.PrivateKey) ([]byte, error) + func ValidateCertificate(ctx context.Context, cert *x509.Certificate, roots *CertificatePool, ...) error + func Verify(ctx context.Context, contents, signature []byte, publicKey *rsa.PublicKey) error + type CertificatePool struct + func NewCertificatePool(ctx context.Context, emptyPool bool) (*CertificatePool, error) + func (p *CertificatePool) AddPEMCertificatesFromFile(ctx context.Context, file string) error + type ErrArmorPGPKeyFailure struct + Bits int + Email string + Err error + KeyType string + Name string + func (e *ErrArmorPGPKeyFailure) Code() int + func (e *ErrArmorPGPKeyFailure) Error() string + func (e *ErrArmorPGPKeyFailure) InternalError() error + type ErrDecodeFailure struct + Err error + func (e *ErrDecodeFailure) Code() int + func (e *ErrDecodeFailure) Error() string + func (e *ErrDecodeFailure) InternalError() error + type ErrDecryptFailure struct + Err error + func (e *ErrDecryptFailure) Code() int + func (e *ErrDecryptFailure) Error() string + func (e *ErrDecryptFailure) InternalError() error + type ErrEncodeFailure struct + Err error + func (e *ErrEncodeFailure) Code() int + func (e *ErrEncodeFailure) Error() string + func (e *ErrEncodeFailure) InternalError() error + type ErrEncryptFailure struct + Err error + func (e *ErrEncryptFailure) Code() int + func (e *ErrEncryptFailure) Error() string + func (e *ErrEncryptFailure) InternalError() error + type ErrExtractPublicKeyFailure struct + Err error + func (e *ErrExtractPublicKeyFailure) Code() int + func (e *ErrExtractPublicKeyFailure) Error() string + func (e *ErrExtractPublicKeyFailure) InternalError() error + type ErrGenerateCertificateFailure struct + Err error + func (e *ErrGenerateCertificateFailure) Code() int + func (e *ErrGenerateCertificateFailure) Error() string + func (e *ErrGenerateCertificateFailure) InternalError() error + type ErrGenerateCipherFailure struct + Err error + func (e *ErrGenerateCipherFailure) Code() int + func (e *ErrGenerateCipherFailure) Error() string + func (e *ErrGenerateCipherFailure) InternalError() error + type ErrGenerateGCMFailure struct + Err error + func (e *ErrGenerateGCMFailure) Code() int + func (e *ErrGenerateGCMFailure) Error() string + func (e *ErrGenerateGCMFailure) InternalError() error + type ErrGenerateIVFailure struct + Err error + func (e *ErrGenerateIVFailure) Code() int + func (e *ErrGenerateIVFailure) Error() string + func (e *ErrGenerateIVFailure) InternalError() error + type ErrGenerateNonceFailure struct + Err error + func (e *ErrGenerateNonceFailure) Code() int + func (e *ErrGenerateNonceFailure) Error() string + func (e *ErrGenerateNonceFailure) InternalError() error + type ErrGeneratePGPKeyFailure struct + Bits int + Email string + Err error + KeyType string + Name string + func (e *ErrGeneratePGPKeyFailure) Code() int + func (e *ErrGeneratePGPKeyFailure) Error() string + func (e *ErrGeneratePGPKeyFailure) InternalError() error + type ErrGeneratePrivateKeyFailure struct + Err error + func (e *ErrGeneratePrivateKeyFailure) Code() int + func (e *ErrGeneratePrivateKeyFailure) Error() string + func (e *ErrGeneratePrivateKeyFailure) InternalError() error + type ErrGenerateRandomKeyFailure struct + Err error + func (e *ErrGenerateRandomKeyFailure) Code() int + func (e *ErrGenerateRandomKeyFailure) Error() string + func (e *ErrGenerateRandomKeyFailure) InternalError() error + type ErrGetPGPKeyFailure struct + Err error + func (e *ErrGetPGPKeyFailure) Code() int + func (e *ErrGetPGPKeyFailure) Error() string + func (e *ErrGetPGPKeyFailure) InternalError() error + type ErrInvalidCertificate struct + CommonName string + Err error + ExpectedCommonName string + func (e *ErrInvalidCertificate) Code() int + func (e *ErrInvalidCertificate) Error() string + func (e *ErrInvalidCertificate) InternalError() error + type ErrInvalidSignature struct + Err error + func (e *ErrInvalidSignature) Code() int + func (e *ErrInvalidSignature) Error() string + func (e *ErrInvalidSignature) InternalError() error + type ErrInvalidTokenClaims struct + Err error + func (e *ErrInvalidTokenClaims) Code() int + func (e *ErrInvalidTokenClaims) Error() string + func (e *ErrInvalidTokenClaims) InternalError() error + type ErrInvalidTokenSignatureAlgorithm struct + Alg interface{} + Expected string + func (e *ErrInvalidTokenSignatureAlgorithm) Code() int + func (e *ErrInvalidTokenSignatureAlgorithm) Error() string + func (e *ErrInvalidTokenSignatureAlgorithm) InternalError() error + type ErrLoadCertificateFailure struct + Err error + func (e *ErrLoadCertificateFailure) Code() int + func (e *ErrLoadCertificateFailure) Error() string + func (e *ErrLoadCertificateFailure) InternalError() error + type ErrLoadPGPKeyFailure struct + Err error + func (e *ErrLoadPGPKeyFailure) Code() int + func (e *ErrLoadPGPKeyFailure) Error() string + func (e *ErrLoadPGPKeyFailure) InternalError() error + type ErrLockPGPKeyFailure struct + Bits int + Email string + Err error + KeyType string + Name string + func (e *ErrLockPGPKeyFailure) Code() int + func (e *ErrLockPGPKeyFailure) Error() string + func (e *ErrLockPGPKeyFailure) InternalError() error + type ErrParseCertificateFailure struct + Err error + func (e *ErrParseCertificateFailure) Code() int + func (e *ErrParseCertificateFailure) Error() string + func (e *ErrParseCertificateFailure) InternalError() error + type ErrParseJWTTokenFailure struct + Err error + func (e *ErrParseJWTTokenFailure) Code() int + func (e *ErrParseJWTTokenFailure) Error() string + func (e *ErrParseJWTTokenFailure) InternalError() error + type ErrReadFileFailure struct + Err error + File string + func (e *ErrReadFileFailure) Code() int + func (e *ErrReadFileFailure) Error() string + func (e *ErrReadFileFailure) InternalError() error + type ErrSignDataFailure struct + Err error + func (e *ErrSignDataFailure) Code() int + func (e *ErrSignDataFailure) Error() string + func (e *ErrSignDataFailure) InternalError() error + type ErrSignJWTTokenFailure struct + Err error + func (e *ErrSignJWTTokenFailure) Code() int + func (e *ErrSignJWTTokenFailure) Error() string + func (e *ErrSignJWTTokenFailure) InternalError() error + type ErrUnlockPGPKeyFailure struct + Err error + func (e *ErrUnlockPGPKeyFailure) Code() int + func (e *ErrUnlockPGPKeyFailure) Error() string + func (e *ErrUnlockPGPKeyFailure) InternalError() error + type JWTAuthECDSAService struct + func NewJWTAuthECDSAService(publicKey *ecdsa.PublicKey, privateKey *ecdsa.PrivateKey) *JWTAuthECDSAService + func (j *JWTAuthECDSAService) GenerateToken(ctx context.Context, claims jwt.Claims) (string, error) + func (j *JWTAuthECDSAService) VerifyToken(ctx context.Context, encodedToken string) (*jwt.Token, error) + type JWTAuthHMACService struct + func NewJWTAuthHMACService(secret []byte) *JWTAuthHMACService + func (j *JWTAuthHMACService) GenerateToken(ctx context.Context, claims jwt.Claims) (string, error) + func (j *JWTAuthHMACService) VerifyToken(ctx context.Context, encodedToken string) (*jwt.Token, error) + type JWTAuthRSAService struct + func NewJWTAuthRSAService(publicKey *rsa.PublicKey, privateKey *rsa.PrivateKey) *JWTAuthRSAService + func (j *JWTAuthRSAService) GenerateToken(ctx context.Context, claims jwt.Claims) (string, error) + func (j *JWTAuthRSAService) VerifyToken(ctx context.Context, encodedToken string) (*jwt.Token, error) + type JWTAuthService interface + GenerateToken func(jwt.Claims, context.Context) (string, error) + VerifyToken func(string, context.Context) (*jwt.Token, error) + type PEMCipher int + const PEMCipher3DES + const PEMCipherAES128 + const PEMCipherAES192 + const PEMCipherAES256 + const PEMCipherDES + type PGPKeyPair struct + func NewPGPKeyPair(ctx context.Context, name, email, keyType string, bits int) (*PGPKeyPair, error) + func NewPGPKeyPairFromArmor(ctx context.Context, armoredKey, passphrase string) (*PGPKeyPair, error) + func (kp *PGPKeyPair) ClearPrivateParams() + func (kp *PGPKeyPair) GetArmoredPrivateKey(ctx context.Context) (string, error) + func (kp *PGPKeyPair) GetArmoredPublicKey(ctx context.Context) (string, error)