Versions in this module Expand all Collapse all v0 v0.1.0 Jan 19, 2022 v0.0.2 Jan 13, 2022 v0.0.1 Jan 13, 2022 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(file string, ctx context.Context) (*pem.Block, error) + func DecryptPEMBlock(b *pem.Block, password []byte, ctx context.Context) ([]byte, error) + func DecryptString(ciphertext, key string, ctx context.Context) (string, error) + func EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, alg PEMCipher, ...) (*pem.Block, error) + func EncryptString(plaintext, key string, ctx context.Context) (string, error) + func GeneratePassword(passwordLength, minSpecialChar, minNum, minUpperCase int) string + func IsEncryptedPEMBlock(b *pem.Block) bool + func NewSelfSignedCertificateKeyPair(template *x509.Certificate, keyBits int, ctx context.Context) ([]byte, []byte, error) + func ParsePEMCertificateBytes(contents []byte, ctx context.Context) ([]*x509.Certificate, error) + func ParsePEMCertificateFile(file string, ctx context.Context) ([]*x509.Certificate, error) + func ParsePEMPrivateKeyBytes(contents []byte, password []byte, ctx context.Context) (*rsa.PrivateKey, error) + func ParsePEMPrivateKeyFile(file string, password []byte, ctx context.Context) (*rsa.PrivateKey, error) + func ParsePublicKeyFromCertificate(cert *x509.Certificate, ctx context.Context) (*rsa.PublicKey, error) + func Sign(contents []byte, privateKey *rsa.PrivateKey, ctx context.Context) ([]byte, error) + func ValidateCertificate(cert *x509.Certificate, roots *CertificatePool, intermediates *CertificatePool, ...) error + func Verify(contents, signature []byte, publicKey *rsa.PublicKey, ctx context.Context) error + type CertificatePool struct + func NewCertificatePool(emptyPool bool, ctx context.Context) (*CertificatePool, error) + func (p *CertificatePool) AddPEMCertificatesFromFile(file string, ctx context.Context) 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(claims jwt.Claims, ctx context.Context) (string, error) + func (j *JWTAuthECDSAService) VerifyToken(encodedToken string, ctx context.Context) (*jwt.Token, error) + type JWTAuthHMACService struct + func NewJWTAuthHMACService(secret []byte) *JWTAuthHMACService + func (j *JWTAuthHMACService) GenerateToken(claims jwt.Claims, ctx context.Context) (string, error) + func (j *JWTAuthHMACService) VerifyToken(encodedToken string, ctx context.Context) (*jwt.Token, error) + type JWTAuthRSAService struct + func NewJWTAuthRSAService(publicKey *rsa.PublicKey, privateKey *rsa.PrivateKey) *JWTAuthRSAService + func (j *JWTAuthRSAService) GenerateToken(claims jwt.Claims, ctx context.Context) (string, error) + func (j *JWTAuthRSAService) VerifyToken(encodedToken string, ctx context.Context) (*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(name, email, keyType string, bits int, ctx context.Context) (*PGPKeyPair, error) + func NewPGPKeyPairFromArmor(armoredKey, passphrase string, ctx context.Context) (*PGPKeyPair, error) + func (kp *PGPKeyPair) ClearPrivateParams() + func (kp *PGPKeyPair) GetArmoredPrivateKey(ctx context.Context) (string, error) + func (kp *PGPKeyPair) GetArmoredPublicKey(ctx context.Context) (string, error)