Documentation ¶
Index ¶
- Constants
- Variables
- func X3DHInit(ICa, EKa PrivateKey, ICb, LTCb, OTCb PublicKey) ([]byte, error)
- func X3DHRespond(ICa, EKa PublicKey, ICb, LTCb, OTCb PrivateKey) ([]byte, error)
- type CMSEnvelope
- type Cipher
- type Crypto
- type CryptoError
- type CustomParam
- type Envelope
- type KeyType
- type Keypair
- type PFS
- type PFSSession
- type PrivateKey
- type PublicKey
- type StructuralError
- type SyntaxError
- type VirgilChunkCipher
- type VirgilCrypto
- func (c *VirgilCrypto) CalculateFingerprint(data []byte) []byte
- func (c *VirgilCrypto) Decrypt(data []byte, key PrivateKey) ([]byte, error)
- func (c *VirgilCrypto) DecryptStream(in io.Reader, out io.Writer, key PrivateKey) error
- func (c *VirgilCrypto) DecryptThenVerify(data []byte, decryptionKey PrivateKey, verifierKeys ...PublicKey) ([]byte, error)
- func (c *VirgilCrypto) Encrypt(data []byte, recipients ...PublicKey) ([]byte, error)
- func (c *VirgilCrypto) EncryptStream(in io.Reader, out io.Writer, recipients ...PublicKey) error
- func (c *VirgilCrypto) ExportPrivateKey(key PrivateKey, password string) ([]byte, error)
- func (c *VirgilCrypto) ExportPublicKey(key PublicKey) ([]byte, error)
- func (c *VirgilCrypto) ExtractPublicKey(key PrivateKey) (PublicKey, error)
- func (c *VirgilCrypto) GenerateKeypair() (Keypair, error)
- func (c *VirgilCrypto) ImportPrivateKey(data []byte, password string) (PrivateKey, error)
- func (c *VirgilCrypto) ImportPublicKey(data []byte) (PublicKey, error)
- func (c *VirgilCrypto) SetKeyType(keyType KeyType) error
- func (c *VirgilCrypto) Sign(data []byte, signer PrivateKey) ([]byte, error)
- func (c *VirgilCrypto) SignStream(in io.Reader, signer PrivateKey) ([]byte, error)
- func (c *VirgilCrypto) SignThenEncrypt(data []byte, signerKey PrivateKey, recipients ...PublicKey) ([]byte, error)
- func (c *VirgilCrypto) StartInitiatorSession(ICb, LTCb, OTCb PublicKey, ICa, EKa PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error)
- func (c *VirgilCrypto) StartResponderSession(ICa, EKa PublicKey, ICb, LTCb, OTCb PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error)
- func (c *VirgilCrypto) Verify(data []byte, signature []byte, key PublicKey) (bool, error)
- func (c *VirgilCrypto) VerifyStream(in io.Reader, signature []byte, key PublicKey) (bool, error)
- type VirgilHash
- type VirgilSigner
- type VirgilStreamCipher
- type VirgilVerifier
- type WrongPasswordError
Constants ¶
View Source
const Curve25519PrivateKeySize = 32
View Source
const Curve25519PublicKeySize = 32
View Source
const EC_PRIVATE_KEY = "PRIVATE KEY"
View Source
const ENCRYPTED_PRIVATE_KEY = "ENCRYPTED PRIVATE KEY"
View Source
const MINIMAL_KEY_LENGTH = 32
View Source
const PUBLIC_KEY = "PUBLIC KEY"
Variables ¶
View Source
var ( // ErrInvalidBlockSize indicates hash blocksize <= 0. ErrInvalidBlockSize = CryptoError("invalid blocksize") // ErrInvalidPKCS7Data indicates bad input to PKCS7 pad or unpad. ErrInvalidPKCS7Data = CryptoError("invalid PKCS7 data (empty or not padded)") // ErrInvalidPKCS7Padding indicates PKCS7 unpad fails to bad input. ErrInvalidPKCS7Padding = CryptoError("invalid padding on input") )
View Source
var DefaultChunkSize = 1024 * 1024
View Source
var NewKeypair func() (Keypair, error)
Functions ¶
func X3DHInit ¶ added in v4.0.3
func X3DHInit(ICa, EKa PrivateKey, ICb, LTCb, OTCb PublicKey) ([]byte, error)
func X3DHRespond ¶ added in v4.0.3
func X3DHRespond(ICa, EKa PublicKey, ICb, LTCb, OTCb PrivateKey) ([]byte, error)
Types ¶
type CMSEnvelope ¶
type CMSEnvelope struct { ContentType asn1.ObjectIdentifier Content envelopedData `asn1:"tag:0,explicit"` }
type Cipher ¶
type Cipher interface { AddKeyRecipient(key *ed25519PublicKey) error AddPasswordRecipient(password []byte) Encrypt(data []byte) ([]byte, error) DecryptWithPassword(data []byte, password []byte) ([]byte, error) DecryptWithPrivateKey(data []byte, key *ed25519PrivateKey) ([]byte, error) EncryptStream(in io.Reader, out io.Writer) error DecryptStream(in io.Reader, out io.Writer, key *ed25519PrivateKey) error SignThenEncrypt(data []byte, signerKey *ed25519PrivateKey) ([]byte, error) DecryptThenVerify(data []byte, decryptionKey *ed25519PrivateKey, verifierPublicKeys ...*ed25519PublicKey) ([]byte, error) }
type Crypto ¶
type Crypto interface { SetKeyType(keyType KeyType) error GenerateKeypair() (Keypair, error) ImportPrivateKey(data []byte, password string) (PrivateKey, error) ImportPublicKey(data []byte) (PublicKey, error) ExportPrivateKey(key PrivateKey, password string) ([]byte, error) ExportPublicKey(key PublicKey) ([]byte, error) Encrypt(data []byte, recipients ...PublicKey) ([]byte, error) EncryptStream(in io.Reader, out io.Writer, recipients ...PublicKey) error Decrypt(data []byte, key PrivateKey) ([]byte, error) DecryptStream(in io.Reader, out io.Writer, key PrivateKey) error DecryptThenVerify(data []byte, privateKeyForDecryption PrivateKey, verifierKey ...PublicKey) ([]byte, error) Sign(data []byte, signer PrivateKey) ([]byte, error) SignStream(in io.Reader, signer PrivateKey) ([]byte, error) SignThenEncrypt(data []byte, signerKey PrivateKey, recipients ...PublicKey) ([]byte, error) //Verify must return non nil error if the result is false Verify(data []byte, signature []byte, key PublicKey) (bool, error) VerifyStream(in io.Reader, signature []byte, key PublicKey) (bool, error) CalculateFingerprint(data []byte) []byte ExtractPublicKey(key PrivateKey) (PublicKey, error) }
var DefaultCrypto Crypto
type CryptoError ¶
type CryptoError string
func (CryptoError) Error ¶
func (c CryptoError) Error() string
type CustomParam ¶
type Envelope ¶
type Envelope struct { Version int Data CMSEnvelope CustomParams []CustomParam `asn1:"set,explicit,optional"` }
type KeyType ¶
type KeyType int
KeyType denotes algorithm used for key generation. See keytypes package
type Keypair ¶
type Keypair interface { HasPublic() bool HasPrivate() bool PublicKey() PublicKey PrivateKey() PrivateKey }
type PFS ¶ added in v4.0.3
type PFS interface { StartInitiatorSession(ICb, LTCb, OTCb PublicKey, ICa, EKa PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error) StartResponderSession(ICa, EKa PublicKey, ICb, LTCb, OTCb PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error) }
type PFSSession ¶ added in v4.0.3
type PFSSession struct {
SK, AD, SessionID []byte
}
func (*PFSSession) Decrypt ¶ added in v4.0.3
func (s *PFSSession) Decrypt(salt, ciphertext []byte) ([]byte, error)
func (*PFSSession) Encrypt ¶ added in v4.0.3
func (s *PFSSession) Encrypt(plaintext []byte) (salt, ciphertext []byte)
type PrivateKey ¶
type PrivateKey interface { ReceiverID() []byte ExtractPublicKey() (PublicKey, error) Encode(password []byte) ([]byte, error) Empty() bool }
func DecodePrivateKey ¶
func DecodePrivateKey(keyBytes, password []byte) (key PrivateKey, err error)
type PublicKey ¶
func DecodePublicKey ¶
type StructuralError ¶
type StructuralError struct {
Msg string
}
A StructuralError suggests that the ASN.1 data is valid, but the Go type which is receiving it doesn't match.
func (StructuralError) Error ¶
func (e StructuralError) Error() string
type SyntaxError ¶
type SyntaxError struct {
Msg string
}
A SyntaxError suggests that the ASN.1 data is invalid.
func (SyntaxError) Error ¶
func (e SyntaxError) Error() string
type VirgilChunkCipher ¶
type VirgilChunkCipher interface { Encrypt(key, nonce, ad []byte, chunkSize int, in io.Reader, out io.Writer) error Decrypt(key, nonce, ad []byte, chunkSize int, in io.Reader, out io.Writer) error }
var ChunkCipher VirgilChunkCipher
type VirgilCrypto ¶
type VirgilCrypto struct {
Cipher func() Cipher
}
func (*VirgilCrypto) CalculateFingerprint ¶
func (c *VirgilCrypto) CalculateFingerprint(data []byte) []byte
func (*VirgilCrypto) Decrypt ¶
func (c *VirgilCrypto) Decrypt(data []byte, key PrivateKey) ([]byte, error)
func (*VirgilCrypto) DecryptStream ¶
func (c *VirgilCrypto) DecryptStream(in io.Reader, out io.Writer, key PrivateKey) error
func (*VirgilCrypto) DecryptThenVerify ¶
func (c *VirgilCrypto) DecryptThenVerify(data []byte, decryptionKey PrivateKey, verifierKeys ...PublicKey) ([]byte, error)
func (*VirgilCrypto) Encrypt ¶
func (c *VirgilCrypto) Encrypt(data []byte, recipients ...PublicKey) ([]byte, error)
func (*VirgilCrypto) EncryptStream ¶
func (*VirgilCrypto) ExportPrivateKey ¶
func (c *VirgilCrypto) ExportPrivateKey(key PrivateKey, password string) ([]byte, error)
func (*VirgilCrypto) ExportPublicKey ¶
func (c *VirgilCrypto) ExportPublicKey(key PublicKey) ([]byte, error)
func (*VirgilCrypto) ExtractPublicKey ¶
func (c *VirgilCrypto) ExtractPublicKey(key PrivateKey) (PublicKey, error)
func (*VirgilCrypto) GenerateKeypair ¶
func (c *VirgilCrypto) GenerateKeypair() (Keypair, error)
func (*VirgilCrypto) ImportPrivateKey ¶
func (c *VirgilCrypto) ImportPrivateKey(data []byte, password string) (PrivateKey, error)
func (*VirgilCrypto) ImportPublicKey ¶
func (c *VirgilCrypto) ImportPublicKey(data []byte) (PublicKey, error)
func (*VirgilCrypto) SetKeyType ¶
func (c *VirgilCrypto) SetKeyType(keyType KeyType) error
func (*VirgilCrypto) Sign ¶
func (c *VirgilCrypto) Sign(data []byte, signer PrivateKey) ([]byte, error)
func (*VirgilCrypto) SignStream ¶
func (c *VirgilCrypto) SignStream(in io.Reader, signer PrivateKey) ([]byte, error)
func (*VirgilCrypto) SignThenEncrypt ¶
func (c *VirgilCrypto) SignThenEncrypt(data []byte, signerKey PrivateKey, recipients ...PublicKey) ([]byte, error)
func (*VirgilCrypto) StartInitiatorSession ¶ added in v4.0.3
func (c *VirgilCrypto) StartInitiatorSession(ICb, LTCb, OTCb PublicKey, ICa, EKa PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error)
func (*VirgilCrypto) StartResponderSession ¶ added in v4.0.3
func (c *VirgilCrypto) StartResponderSession(ICa, EKa PublicKey, ICb, LTCb, OTCb PrivateKey, aliceCardId, bobCardId string) (sess *PFSSession, err error)
func (*VirgilCrypto) VerifyStream ¶
type VirgilHash ¶
var Hash VirgilHash
type VirgilSigner ¶
type VirgilSigner interface { Sign(data []byte, signer PrivateKey) ([]byte, error) SignStream(data io.Reader, signer PrivateKey) ([]byte, error) }
var Signer VirgilSigner
type VirgilStreamCipher ¶
type VirgilStreamCipher interface { Encrypt(key, nonce, ad []byte, in io.Reader, out io.Writer) error Decrypt(key, nonce, ad []byte, in io.Reader, out io.Writer) error }
var StreamCipher VirgilStreamCipher
type VirgilVerifier ¶
type VirgilVerifier interface { Verify(data []byte, key PublicKey, signature []byte) (bool, error) VerifyStream(data io.Reader, key PublicKey, signature []byte) (bool, error) }
var Verifier VirgilVerifier
type WrongPasswordError ¶
type WrongPasswordError struct {
CryptoError
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.