Documentation ¶
Index ¶
- Constants
- Variables
- type Provider
- func (p Provider) DecryptAES(ctx context.Context, ciphertext []byte) ([]byte, error)
- func (p Provider) DecryptRSA(ctx context.Context, ciphertext []byte) ([]byte, error)
- func (p Provider) EncryptAES(ctx context.Context, plaintext []byte) ([]byte, error)
- func (p Provider) EncryptRSA(ctx context.Context, plaintext []byte) ([]byte, error)
- func (p *Provider) RegisterKeyAES(data []byte) error
- func (p *Provider) RegisterPrivateKeyECDSA(data []byte) error
- func (p *Provider) RegisterPrivateKeyRSA(data []byte) error
- func (p Provider) SignECDSA(ctx context.Context, plaintext []byte) ([]byte, error)
- func (p Provider) VerifyECDSA(ctx context.Context, signature, plaintext []byte) error
Constants ¶
const ( TypeECDSA = "EC PRIVATE KEY" TypeRSAPKCS1 = "RSA PRIVATE KEY" TypeRSAPKCS8 = "PRIVATE KEY" TypeAES = "AES KEY" )
PEM Block types
Variables ¶
var ( // ErrECDSADecodePEM defines error of PEM decoding for ECDSA key ErrECDSADecodePEM = errors.New("failed to decode PEM block containing ECDSA private key") // ErrECDSAVerifyFalse defines error if signature is not valid for given message ErrECDSAVerifyFalse = errors.New("signature is not valid for given message") // ErrECDSANotDefined defines error if ECDSA private key is not defined ErrECDSANotDefined = errors.New("ECDSA private key is not defined") // ErrRSADecodePEM defines error of PEM decoding for RSA key ErrRSADecodePEM = errors.New("failed to decode PEM block containing RSA private key") // ErrRSAUnknown defines error for unknown type of RSA key ErrRSAUnknown = errors.New("unknown type of RSA private key") // ErrRSANotDefined defines error if RSA private key is not defined ErrRSANotDefined = errors.New("RSA private key is not defined") // ErrAESDecodePEM defines error of PEM decoding for AES key ErrAESDecodePEM = errors.New("failed to decode PEM block containing AES key") // ErrAESNotDefined defines error if AES key is not defined ErrAESNotDefined = errors.New("AES key is not defined") )
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements private crypto provider
func New ¶
func New(ecdsaKey *ecdsa.PrivateKey, rsaKey *rsa.PrivateKey, aesKey []byte) *Provider
New creates a new crypto provider initialized by ECDSA, RSA private keys and AES key
func (Provider) DecryptAES ¶
DecryptAES will attempt to decrypt a given ciphertext with an AES-256 key
func (Provider) DecryptRSA ¶
DecryptRSA will attempt to decrypt a given ciphertext with an RSA 2048 private key
func (Provider) EncryptAES ¶
EncryptAES will encrypt a plaintext using an AES-256 key
func (Provider) EncryptRSA ¶
EncryptRSA will encrypt a plaintext message using an RSA 2048 public key plaintext message length is maximum 240 bytes (2048 bits minus padding: 11 bytes for PKCS#1 v1.5 padding)
func (*Provider) RegisterKeyAES ¶
RegisterKeyAES decodes and adds AES key from specified PEM block
func (*Provider) RegisterPrivateKeyECDSA ¶
RegisterPrivateKeyECDSA decodes and register ECDSA private key from specified PEM block
func (*Provider) RegisterPrivateKeyRSA ¶
RegisterPrivateKeyRSA decodes and register RSA private key from specified PEM block