Documentation ¶
Overview ¶
Package crypto implements all cryptographic functions used by the 3nigm4 suite: i mainly wrap Golang std lib function and implement specific pre-processing and post-processing logics. This is a security related element and should be modified with care: any change to this package can potentially modify the security of the whole system.
Index ¶
- func AesDecrypt(key []byte, ciphertext []byte, mode AesMode) ([]byte, error)
- func AesEncrypt(key []byte, salt []byte, plaintext []byte, mode AesMode) ([]byte, error)
- func CheckHMAC(message []byte, messageMAC []byte, key []byte) bool
- func DecodePgpArmored(data []byte) ([]byte, error)
- func DeriveKeyWithPbkdf2(password []byte, salt []byte, iter int) []byte
- func EncodePgpArmored(data []byte, blocktype string) ([]byte, error)
- func GenerateHMAC(message []byte, key []byte) []byte
- func GetKeyByEmail(keyring openpgp.EntityList, email string) *openpgp.Entity
- func GetSaltFromCipherText(ciphertext []byte) ([]byte, error)
- func NewPgpKeypair(name, comment, email string) ([]byte, []byte, error)
- func OpenPgpDecrypt(data []byte, keyring openpgp.EntityList) ([]byte, error)
- func OpenPgpEncrypt(data []byte, recipients openpgp.EntityList, signer *openpgp.Entity) ([]byte, error)
- func OpenPgpSignMessage(msg []byte, signer *openpgp.Entity) ([]byte, error)
- func OpenPgpVerifySignature(signature []byte, message []byte, publicKey *openpgp.Entity) error
- func PKCS5Padding(src []byte, blockSize int) []byte
- func PKCS5UnPadding(src []byte) ([]byte, error)
- func ReadArmoredKeyRing(kr []byte, passphrase []byte) (openpgp.EntityList, error)
- func XorKeys(keys [][]byte, maxlen int) ([]byte, error)
- type AesMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
AesDecrypt decrypt data with AES256 using a key Salt and IV are passed in the encrypted message.
func AesEncrypt ¶
AesEncrypt encrypt data with AES256 using a key. Salt and IV will be passed in the encrypted message.
func DecodePgpArmored ¶
DecodePgpArmored decode pgp armored messages from ASCII armored format.
func DeriveKeyWithPbkdf2 ¶
DeriveKeyWithPbkdf2 derive a key from a password using Pbkdf2 algorithm. A good number of iterations is ~ 10000 cycles. The derivated key has the right lenght for being used in AES256.
func EncodePgpArmored ¶
EncodePgpArmored encode a pgp message in armored ASCII format.
func GenerateHMAC ¶
GenerateHMAC produce hmac with a message and a key.
func GetKeyByEmail ¶
func GetKeyByEmail(keyring openpgp.EntityList, email string) *openpgp.Entity
GetKeyByEmail returns a specific key from an email address.
func GetSaltFromCipherText ¶
GetSaltFromCipherText extract the salt component from an encrypted data blob.
func NewPgpKeypair ¶
NewPgpKeypair creates a pgp keypair and encodes them as byte slides. No encryption is introduced at that point.
func OpenPgpDecrypt ¶
func OpenPgpDecrypt(data []byte, keyring openpgp.EntityList) ([]byte, error)
OpenPgpDecrypt decrypt a message using the argument keyring as source to get required keys.
func OpenPgpEncrypt ¶
func OpenPgpEncrypt(data []byte, recipients openpgp.EntityList, signer *openpgp.Entity) ([]byte, error)
OpenPgpEncrypt encrypt using pgp and the passed recipients list and signer entity.
func OpenPgpSignMessage ¶
OpenPgpSignMessage creates a signature for a message.
func OpenPgpVerifySignature ¶
OpenPgpVerifySignature verify a signature using a public PGP key, an error is returned if the signature is not verified otherwise returning nil.
func PKCS5Padding ¶
PKCS5Padding padding function to pad a certain blob of data with necessary data to be used in AES block cipher.
func PKCS5UnPadding ¶
PKCS5UnPadding unpad data after AES block decrypting.
func ReadArmoredKeyRing ¶
func ReadArmoredKeyRing(kr []byte, passphrase []byte) (openpgp.EntityList, error)
ReadArmoredKeyRing read keys in an armored keyring and returns openpgp entities. If a passphrase is passed it will be used to decrypt keys.