cryptogo

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 24 Imported by: 18

Documentation

Index

Constants

View Source
const (
	AES_128_KEY_SIZE_BITS  = 128
	AES_128_KEY_SIZE_BYTES = AES_128_KEY_SIZE_BITS / 8

	AES_256_KEY_SIZE_BITS  = 256
	AES_256_KEY_SIZE_BYTES = AES_256_KEY_SIZE_BITS / 8

	MIN_PASSWORD = 12
)

Variables

View Source
var CompressionAlgorithm_name = map[int32]string{
	0: "UNKNOWN_COMPRESSION",
}
View Source
var CompressionAlgorithm_value = map[string]int32{
	"UNKNOWN_COMPRESSION": 0,
}
View Source
var EncryptionAlgorithm_name = map[int32]string{
	0: "UNKNOWN_ENCRYPTION",
	1: "AES_128_GCM_NOPADDING",
	2: "PBKDF2WITHHMACSHA1",
	3: "RSA_ECB_OAEPPADDING",
	4: "AES_256_GCM_NOPADDING",
}
View Source
var EncryptionAlgorithm_value = map[string]int32{
	"UNKNOWN_ENCRYPTION":    0,
	"AES_128_GCM_NOPADDING": 1,
	"PBKDF2WITHHMACSHA1":    2,
	"RSA_ECB_OAEPPADDING":   3,
	"AES_256_GCM_NOPADDING": 4,
}
View Source
var PrivateKeyFormat_name = map[int32]string{
	0: "UNKNOWN_PRIVATE_KEY_FORMAT",
	1: "PKCS1_PRIVATE",
	2: "PKCS8",
}
View Source
var PrivateKeyFormat_value = map[string]int32{
	"UNKNOWN_PRIVATE_KEY_FORMAT": 0,
	"PKCS1_PRIVATE":              1,
	"PKCS8":                      2,
}
View Source
var PublicKeyFormat_name = map[int32]string{
	0: "UNKNOWN_PUBLIC_KEY_FORMAT",
	1: "PKCS1_PUBLIC",
	2: "PKIX",
	3: "X509",
}
View Source
var PublicKeyFormat_value = map[string]int32{
	"UNKNOWN_PUBLIC_KEY_FORMAT": 0,
	"PKCS1_PUBLIC":              1,
	"PKIX":                      2,
	"X509":                      3,
}
View Source
var SignatureAlgorithm_name = map[int32]string{
	0: "UNKNOWN_SIGNATURE",
	1: "SHA512WITHRSA",
	2: "SHA512WITHRSA_PSS",
}
View Source
var SignatureAlgorithm_value = map[string]int32{
	"UNKNOWN_SIGNATURE": 0,
	"SHA512WITHRSA":     1,
	"SHA512WITHRSA_PSS": 2,
}

Functions

func CreateRSAPrivateKey

func CreateRSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)

func CreateSignature

func CreateSignature(algorithm SignatureAlgorithm, privateKey *rsa.PrivateKey, data []byte) ([]byte, error)

func DecryptAESGCM

func DecryptAESGCM(key, encrypted []byte) ([]byte, error)

func DecryptKey

func DecryptKey(algorithm EncryptionAlgorithm, secret []byte, key *rsa.PrivateKey) ([]byte, error)

func DecryptPayload

func DecryptPayload(algorithm EncryptionAlgorithm, payload []byte, key []byte) ([]byte, error)

func EncryptAESGCM

func EncryptAESGCM(key, payload []byte) ([]byte, error)

func ExportKeys

func ExportKeys(host, keystore, name string, password []byte) (string, error)

func GenerateRandomKey

func GenerateRandomKey(bytes int) ([]byte, error)

func HasRSAPrivateKey

func HasRSAPrivateKey(directory, name string) bool

func Hash

func Hash(data []byte) []byte

func HashProtobuf

func HashProtobuf(protobuf proto.Message) ([]byte, error)

func ImportKeys

func ImportKeys(host, keystore, name, accessCode string) error

func KeyShareHandler

func KeyShareHandler(keys KeyShareStore, timeout time.Duration) func(w