Documentation ¶
Index ¶
- func Deserialize(serialized []byte) (*CiphertextBlob, *CryptoConfig, error)
- func ExtractUnverifiedAAD(ciphertext []byte) ([]byte, error)
- func GetMaxSupportedVersion() uint8
- func HMAC(algo MessageDigestAlgorithm, key *PeacemakrKey, buf []byte) ([]byte, error)
- func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)
- func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error)
- func PeacemakrInit() bool
- func Serialize(blob *CiphertextBlob) ([]byte, error)
- func Sign(senderKey *PeacemakrKey, plaintext Plaintext, ciphertext *CiphertextBlob) error
- func Verify(senderKey *PeacemakrKey, plaintext *Plaintext, ciphertext *CiphertextBlob) error
- type AsymmetricCipher
- type CiphertextBlob
- type CryptoConfig
- type DecryptCode
- type EncryptionMode
- type MessageDigestAlgorithm
- type PeacemakrKey
- func NewPeacemakrKey(config CryptoConfig, rand RandomDevice) *PeacemakrKey
- func NewPeacemakrKeyFromBytes(config CryptoConfig, contents []byte) *PeacemakrKey
- func NewPrivateKeyFromPEM(contents string, cfg *CryptoConfig) (*PeacemakrKey, error)
- func NewPublicKeyFromPEM(contents string, cfg *CryptoConfig) (*PeacemakrKey, error)
- func NewSymmetricKeyFromPassword(keylenBits int, passwordStr string, iterationCount int) (*PeacemakrKey, []byte, error)
- func SymmetricKeyFromBytes(keyBytes []byte) (*PeacemakrKey, error)
- func SymmetricKeyFromPasswordAndSalt(keylenBits int, passwordStr string, salt []byte, iterationCount int) (*PeacemakrKey, error)
- func (k *PeacemakrKey) Bytes() ([]byte, error)
- func (k *PeacemakrKey) Config() (CryptoConfig, error)
- func (k *PeacemakrKey) Destroy()
- func (k *PeacemakrKey) ECDHKeygen(peerKey *PeacemakrKey) *PeacemakrKey
- func (k *PeacemakrKey) HKDFKeygen(config CryptoConfig, keyID []byte) (*PeacemakrKey, error)
- func (k *PeacemakrKey) IsValid() bool
- type Plaintext
- type RandomDevice
- type SymmetricCipher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
func Deserialize(serialized []byte) (*CiphertextBlob, *CryptoConfig, error)
func ExtractUnverifiedAAD ¶
func GetMaxSupportedVersion ¶
func GetMaxSupportedVersion() uint8
func HMAC ¶
func HMAC(algo MessageDigestAlgorithm, key *PeacemakrKey, buf []byte) ([]byte, error)
func ParseRsaPrivateKeyFromPemStr ¶ added in v0.0.4
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)
func ParseRsaPublicKeyFromPemStr ¶ added in v0.0.4
func PeacemakrInit ¶
func PeacemakrInit() bool
func Serialize ¶
func Serialize(blob *CiphertextBlob) ([]byte, error)
func Sign ¶
func Sign(senderKey *PeacemakrKey, plaintext Plaintext, ciphertext *CiphertextBlob) error
func Verify ¶
func Verify(senderKey *PeacemakrKey, plaintext *Plaintext, ciphertext *CiphertextBlob) error
Types ¶
type AsymmetricCipher ¶
type AsymmetricCipher int
const ( NONE AsymmetricCipher = 0 RSA_2048 AsymmetricCipher = 1 RSA_4096 AsymmetricCipher = 2 ECDH_P256 AsymmetricCipher = 3 ECDH_P384 AsymmetricCipher = 4 ECDH_P521 AsymmetricCipher = 5 )
func GetECKeyTypeFromPrivPemStr ¶ added in v0.0.6
func GetECKeyTypeFromPrivPemStr(pubPEM string) (AsymmetricCipher, error)
func GetECKeyTypeFromPubPemStr ¶ added in v0.0.4
func GetECKeyTypeFromPubPemStr(pubPEM string) (AsymmetricCipher, error)
type CiphertextBlob ¶
type CiphertextBlob struct {
// contains filtered or unexported fields
}
func Encrypt ¶
func Encrypt(key *PeacemakrKey, plaintext Plaintext, rand RandomDevice) (*CiphertextBlob, error)
type CryptoConfig ¶
type CryptoConfig struct { Mode EncryptionMode SymmetricCipher SymmetricCipher AsymmetricCipher AsymmetricCipher DigestAlgorithm MessageDigestAlgorithm }
func GetConfigFromPrivKey ¶ added in v0.0.6
func GetConfigFromPrivKey(privKey string) (CryptoConfig, error)
func GetConfigFromPubKey ¶ added in v0.0.4
func GetConfigFromPubKey(pubKey string) (CryptoConfig, error)
type DecryptCode ¶
type DecryptCode int
const ( DECRYPT_SUCCESS DecryptCode = 0 DECRYPT_NEED_VERIFY DecryptCode = 1 DECRYPT_FAILED DecryptCode = 2 )
type EncryptionMode ¶
type EncryptionMode int
const ( SYMMETRIC EncryptionMode = 0 ASYMMETRIC EncryptionMode = 1 )
type MessageDigestAlgorithm ¶
type MessageDigestAlgorithm int
const ( SHA_224 MessageDigestAlgorithm = 0 SHA_256 MessageDigestAlgorithm = 1 SHA_384 MessageDigestAlgorithm = 2 SHA_512 MessageDigestAlgorithm = 3 )
type PeacemakrKey ¶
type PeacemakrKey struct {
// contains filtered or unexported fields
}
func NewPeacemakrKey ¶
func NewPeacemakrKey(config CryptoConfig, rand RandomDevice) *PeacemakrKey
func NewPeacemakrKeyFromBytes ¶
func NewPeacemakrKeyFromBytes(config CryptoConfig, contents []byte) *PeacemakrKey
func NewPrivateKeyFromPEM ¶ added in v0.0.6
func NewPrivateKeyFromPEM(contents string, cfg *CryptoConfig) (*PeacemakrKey, error)
func NewPublicKeyFromPEM ¶ added in v0.0.6
func NewPublicKeyFromPEM(contents string, cfg *CryptoConfig) (*PeacemakrKey, error)
func NewSymmetricKeyFromPassword ¶ added in v0.0.6
func SymmetricKeyFromBytes ¶ added in v0.0.6
func SymmetricKeyFromBytes(keyBytes []byte) (*PeacemakrKey, error)
func SymmetricKeyFromPasswordAndSalt ¶ added in v0.0.6
func (*PeacemakrKey) Bytes ¶ added in v0.0.6
func (k *PeacemakrKey) Bytes() ([]byte, error)
func (*PeacemakrKey) Config ¶ added in v0.0.6
func (k *PeacemakrKey) Config() (CryptoConfig, error)
func (*PeacemakrKey) Destroy ¶ added in v0.0.6
func (k *PeacemakrKey) Destroy()
func (*PeacemakrKey) ECDHKeygen ¶ added in v0.0.6
func (k *PeacemakrKey) ECDHKeygen(peerKey *PeacemakrKey) *PeacemakrKey
func (*PeacemakrKey) HKDFKeygen ¶ added in v0.0.6
func (k *PeacemakrKey) HKDFKeygen(config CryptoConfig, keyID []byte) (*PeacemakrKey, error)
func (*PeacemakrKey) IsValid ¶
func (k *PeacemakrKey) IsValid() bool
type Plaintext ¶
func Decrypt ¶
func Decrypt(key *PeacemakrKey, ciphertext *CiphertextBlob) (*Plaintext, bool, error)
type RandomDevice ¶
type RandomDevice struct {
// contains filtered or unexported fields
}
func NewRandomDevice ¶
func NewRandomDevice() RandomDevice
type SymmetricCipher ¶
type SymmetricCipher int
const ( AES_128_GCM SymmetricCipher = 0 AES_192_GCM SymmetricCipher = 1 AES_256_GCM SymmetricCipher = 2 CHACHA20_POLY1305 SymmetricCipher = 3 )
Click to show internal directories.
Click to hide internal directories.