cryptoutil

package
v0.0.0-...-4805961 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SimpleTripleEncryptionHeaderLen int = 4*4 + 96 + 36

Variables

View Source
var CipherTextSizeByKeyType = map[KeyType]KemSizes{
	KeyTypeSidhFp434:      {374, 330, 346, 16},
	KeyTypeSidhFp503:      {434, 378, 402, 24},
	KeyTypeSidhFp751:      {644, 564, 596, 32},
	KeyTypeFrodo640AES:    {19888, 9616, 9720, 16},
	KeyTypeFrodo640SHAKE:  {19888, 9616, 9720, 16},
	KeyTypeFrodo976AES:    {31296, 15632, 15744, 24},
	KeyTypeFrodo976SHAKE:  {31296, 15632, 15744, 24},
	KeyTypeFrodo1344AES:   {43088, 21520, 21632, 32},
	KeyTypeFrodo1344SHAKE: {43088, 21520, 21632, 32},
	KeyTypeKyber512:       {1632, 736, 800, 16},
	KeyTypeKyber768:       {2400, 1088, 1152, 24},
	KeyTypeKyber1024:      {3168, 1568, 1504, 32},
}
View Source
var CurrentSCryptParameters = SCryptParameters{
	N: 65536 * 2,
	R: 8,
	P: 1,
}
View Source
var KeyTypeAsString = map[KeyType]string{
	KeyTypeSidhFp434:      "SIKE_FP434",
	KeyTypeSidhFp503:      "SIKE_FP503",
	KeyTypeSidhFp751:      "SIKE_FP751",
	KeyTypeFrodo640AES:    "FRODO_640_AES",
	KeyTypeFrodo640SHAKE:  "FRODO_640_SHAKE",
	KeyTypeFrodo976AES:    "FRODO_976_AES",
	KeyTypeFrodo976SHAKE:  "FRODO_976_SHAKE",
	KeyTypeFrodo1344AES:   "FRODO_1344_AES",
	KeyTypeFrodo1344SHAKE: "FRODO_1344_SHAKE",
	KeyTypeKyber512:       "KYBER_512",
	KeyTypeKyber768:       "KYBER_768",
	KeyTypeKyber1024:      "KYBER_1024",
}

Functions

func AES256CGMOpen

func AES256CGMOpen(key, nonce, cipherText []byte) (plainText []byte, err error)

func AES256CGMSeal

func AES256CGMSeal(key, nonce, plainText []byte) (cipherText []byte, err error)

func ConcatAll

func ConcatAll(parts ...[]byte) (res []byte)

func Dencapsulate

func Dencapsulate(pub []byte, pvt []byte, ct []byte, keyType KeyType) (ss []byte, err error)

func EncB64

func EncB64(b []byte) string

func Encapsulate

func Encapsulate(pub []byte, keyType KeyType) (ct []byte, ss []byte, err error)

func FrodoGetKem

func FrodoGetKem(keyType KeyType) (kem frodo.FrodoKEM, err error)

func GenKey

func GenKey(keyType KeyType) (pvt []byte, pub []byte, err error)

func KeyId

func KeyId(pub []byte) string

func PrivateKeyAsString

func PrivateKeyAsString(pub []byte) string

func PrivateKeyFromString

func PrivateKeyFromString(key string) (pvt []byte)

func PublicKeyAsString

func PublicKeyAsString(pub []byte) string

func PublicKeyFromString

func PublicKeyFromString(key string) (pub []byte)

func QuickSha256

func QuickSha256(b []byte) []byte

func RandBytes

func RandBytes(size int) []byte

func SikeBytesFromPrivateKey

func SikeBytesFromPrivateKey(pvt *sidh.PrivateKey) []byte

func SikeBytesFromPublicKey

func SikeBytesFromPublicKey(pvt *sidh.PublicKey) []byte

func SikeGetKem

func SikeGetKem(keyType KeyType) (*sidh.KEM, error)

func SikePrivateKeyFromBytes

func SikePrivateKeyFromBytes(b []byte) *sidh.PrivateKey

func SikePublicKeyFromBytes

func SikePublicKeyFromBytes(b []byte) *sidh.PublicKey

func SimpleSuperTripleDecrypt

func SimpleSuperTripleDecrypt(cipherText []byte, password string) (plainText []byte, err error)

func SimpleSuperTripleEncrypt

func SimpleSuperTripleEncrypt(plainText []byte, password string) (cipherText []byte, err error)

Creates a []byte encrypted with Triple AES256-CGM using Scrypt to derive the password.

Types

type KemSizes

type KemSizes struct {
	Private      int
	Public       int
	CipherText   int
	SharedSecret int
}

type KeyType

type KeyType uint8
const (
	KeyTypeUnknown        KeyType = 255
	KeyTypeInvalid        KeyType = iota
	KeyTypeSidhFp434      KeyType = iota
	KeyTypeSidhFp503      KeyType = iota
	KeyTypeSidhFp751      KeyType = iota
	KeyTypeFrodo640AES    KeyType = iota
	KeyTypeFrodo640SHAKE  KeyType = iota
	KeyTypeFrodo976AES    KeyType = iota
	KeyTypeFrodo976SHAKE  KeyType = iota
	KeyTypeFrodo1344AES   KeyType = iota
	KeyTypeFrodo1344SHAKE KeyType = iota
	KeyTypeKyber512       KeyType = iota
	KeyTypeKyber768       KeyType = iota
	KeyTypeKyber1024      KeyType = iota
)

type SCryptParameters

type SCryptParameters struct {
	N uint32
	R uint32
	P uint32
}

type SimpleTripleEncryptionHeader

type SimpleTripleEncryptionHeader struct {
	Magic        uint32
	Salt         [32 * 3]byte
	Nonces       [12 * 3]byte
	SCryptParams SCryptParameters
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL