Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)
- func CreateSignature(algorithm SignatureAlgorithm, privateKey *rsa.PrivateKey, data []byte) ([]byte, error)
- func DecryptAESGCM(key, encrypted []byte) ([]byte, error)
- func DecryptKey(algorithm EncryptionAlgorithm, secret []byte, key *rsa.PrivateKey) ([]byte, error)
- func DecryptPayload(algorithm EncryptionAlgorithm, payload []byte, key []byte) ([]byte, error)
- func EncryptAESGCM(key, payload []byte) ([]byte, error)
- func ExportKeys(host, keystore, name string, password []byte) (string, error)
- func GenerateRandomKey(bytes int) ([]byte, error)
- func HasRSAPrivateKey(directory, name string) bool
- func Hash(data []byte) []byte
- func HashProtobuf(protobuf proto.Message) ([]byte, error)
- func ImportKeys(host, keystore, name, accessCode string) error
- func KeyShareHandler(keys KeyShareStore, timeout time.Duration) func(w http.ResponseWriter, r *http.Request)
- func ListRSAPrivateKeys(directory string) ([]string, error)
- func LoadRSAPrivateKey(directory, name string) (*rsa.PrivateKey, error)
- func ParseRSAPrivateKey(format PrivateKeyFormat, privateKey []byte) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(format PublicKeyFormat, publicKey []byte) (*rsa.PublicKey, error)
- func Password() ([]byte, error)
- func PrivateKeyToRSAPrivateKey(key interface{}) (*rsa.PrivateKey, error)
- func PublicKeyToRSAPublicKey(key interface{}) (*rsa.PublicKey, error)
- func RSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)
- func RSAPrivateKeyFromPKCS1Bytes(data []byte) (*rsa.PrivateKey, error)
- func RSAPrivateKeyFromPKCS8Bytes(data []byte) (*rsa.PrivateKey, error)
- func RSAPrivateKeyToPEM(privateKey *rsa.PrivateKey, password []byte) (*pem.Block, error)
- func RSAPrivateKeyToPKCS1Bytes(privateKey *rsa.PrivateKey) []byte
- func RSAPrivateKeyToPKCS8Bytes(privateKey *rsa.PrivateKey) ([]byte, error)
- func RSAPublicKeyFromPKCS1Bytes(data []byte) (*rsa.PublicKey, error)
- func RSAPublicKeyFromPKIXBytes(data []byte) (*rsa.PublicKey, error)
- func RSAPublicKeyToPEM(publicKey *rsa.PublicKey) (*pem.Block, error)
- func RSAPublicKeyToPKCS1Bytes(publicKey *rsa.PublicKey) []byte
- func RSAPublicKeyToPKIXBytes(publicKey *rsa.PublicKey) ([]byte, error)
- func RandomString(size uint) (string, error)
- func ReadPEM(filename string) (*pem.Block, error)
- func ReadPassword(prompt string) ([]byte, error)
- func VerifySignature(algorithm SignatureAlgorithm, publicKey *rsa.PublicKey, data, signature []byte) error
- func WritePEM(key *pem.Block, filename string) error
- func WriteRSAPrivateKey(privateKey *rsa.PrivateKey, directory, name string, password []byte) error
- type CompressionAlgorithm
- type EncryptionAlgorithm
- type ErrExportFailed
- type ErrPasswordTooShort
- type ErrPasswordsDoNotMatch
- type ErrUnsupportedEncryption
- type ErrUnsupportedPrivateKeyFormat
- type ErrUnsupportedPrivateKeyType
- type ErrUnsupportedPublicKeyFormat
- type ErrUnsupportedPublicKeyType
- type ErrUnsupportedSignature
- type KeyShare
- func (*KeyShare) Descriptor() ([]byte, []int)
- func (m *KeyShare) GetName() string
- func (m *KeyShare) GetPassword() []byte
- func (m *KeyShare) GetPrivateFormat() PrivateKeyFormat
- func (m *KeyShare) GetPrivateKey() []byte
- func (m *KeyShare) GetPublicFormat() PublicKeyFormat
- func (m *KeyShare) GetPublicKey() []byte
- func (*KeyShare) ProtoMessage()
- func (m *KeyShare) Reset()
- func (m *KeyShare) String() string
- func (m *KeyShare) XXX_DiscardUnknown()
- func (m *KeyShare) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *KeyShare) XXX_Merge(src proto.Message)
- func (m *KeyShare) XXX_Size() int
- func (m *KeyShare) XXX_Unmarshal(b []byte) error
- type KeyShareStore
- type PrivateKeyFormat
- type PublicKeyFormat
- type SignatureAlgorithm
Constants ¶
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 ¶
var CompressionAlgorithm_name = map[int32]string{
0: "UNKNOWN_COMPRESSION",
}
var CompressionAlgorithm_value = map[string]int32{
"UNKNOWN_COMPRESSION": 0,
}
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",
}
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,
}
var PrivateKeyFormat_name = map[int32]string{
0: "UNKNOWN_PRIVATE_KEY_FORMAT",
1: "PKCS1_PRIVATE",
2: "PKCS8",
}
var PrivateKeyFormat_value = map[string]int32{
"UNKNOWN_PRIVATE_KEY_FORMAT": 0,
"PKCS1_PRIVATE": 1,
"PKCS8": 2,
}
var PublicKeyFormat_name = map[int32]string{
0: "UNKNOWN_PUBLIC_KEY_FORMAT",
1: "PKCS1_PUBLIC",
2: "PKIX",
3: "X509",
}
var PublicKeyFormat_value = map[string]int32{
"UNKNOWN_PUBLIC_KEY_FORMAT": 0,
"PKCS1_PUBLIC": 1,
"PKIX": 2,
"X509": 3,
}
var SignatureAlgorithm_name = map[int32]string{
0: "UNKNOWN_SIGNATURE",
1: "SHA512WITHRSA",
2: "SHA512WITHRSA_PSS",
}
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 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 GenerateRandomKey ¶
func HasRSAPrivateKey ¶
func ImportKeys ¶
func KeyShareHandler ¶
func KeyShareHandler(keys KeyShareStore, timeout time.Duration) func(w http.ResponseWriter, r *http.Request)
func ListRSAPrivateKeys ¶
func LoadRSAPrivateKey ¶ added in v1.2.0
func LoadRSAPrivateKey(directory, name string) (*rsa.PrivateKey, error)
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(format PrivateKeyFormat, privateKey []byte) (*rsa.PrivateKey, error)
func ParseRSAPublicKey ¶
func ParseRSAPublicKey(format PublicKeyFormat, publicKey []byte) (*rsa.PublicKey, error)
func PrivateKeyToRSAPrivateKey ¶
func PrivateKeyToRSAPrivateKey(key interface{}) (*rsa.PrivateKey, error)
func PublicKeyToRSAPublicKey ¶
func RSAPrivateKey ¶ added in v1.2.0
func RSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)
func RSAPrivateKeyFromPKCS1Bytes ¶
func RSAPrivateKeyFromPKCS1Bytes(data []byte) (*rsa.PrivateKey, error)
func RSAPrivateKeyFromPKCS8Bytes ¶
func RSAPrivateKeyFromPKCS8Bytes(data []byte) (*rsa.PrivateKey, error)
func RSAPrivateKeyToPEM ¶
func RSAPrivateKeyToPKCS1Bytes ¶
func RSAPrivateKeyToPKCS1Bytes(privateKey *rsa.PrivateKey) []byte
func RSAPrivateKeyToPKCS8Bytes ¶
func RSAPrivateKeyToPKCS8Bytes(privateKey *rsa.PrivateKey) ([]byte, error)
func RSAPublicKeyToPKIXBytes ¶
func RandomString ¶
func ReadPassword ¶
func VerifySignature ¶
func VerifySignature(algorithm SignatureAlgorithm, publicKey *rsa.PublicKey, data, signature []byte) error
func WriteRSAPrivateKey ¶
func WriteRSAPrivateKey(privateKey *rsa.PrivateKey, directory, name string, password []byte) error
Types ¶
type CompressionAlgorithm ¶
type CompressionAlgorithm int32
const (
CompressionAlgorithm_UNKNOWN_COMPRESSION CompressionAlgorithm = 0
)
func (CompressionAlgorithm) EnumDescriptor ¶
func (CompressionAlgorithm) EnumDescriptor() ([]byte, []int)
func (CompressionAlgorithm) String ¶
func (x CompressionAlgorithm) String() string
type EncryptionAlgorithm ¶
type EncryptionAlgorithm int32
const ( EncryptionAlgorithm_UNKNOWN_ENCRYPTION EncryptionAlgorithm = 0 EncryptionAlgorithm_AES_128_GCM_NOPADDING EncryptionAlgorithm = 1 EncryptionAlgorithm_PBKDF2WITHHMACSHA1 EncryptionAlgorithm = 2 EncryptionAlgorithm_RSA_ECB_OAEPPADDING EncryptionAlgorithm = 3 EncryptionAlgorithm_AES_256_GCM_NOPADDING EncryptionAlgorithm = 4 )
func (EncryptionAlgorithm) EnumDescriptor ¶
func (EncryptionAlgorithm) EnumDescriptor() ([]byte, []int)
func (EncryptionAlgorithm) String ¶
func (x EncryptionAlgorithm) String() string
type ErrExportFailed ¶ added in v1.2.1
ErrExportFailed is returned when the key cannot be exported.
func (ErrExportFailed) Error ¶ added in v1.2.1
func (e ErrExportFailed) Error() string
type ErrPasswordTooShort ¶ added in v1.2.1
type ErrPasswordTooShort struct {
Size, Min int
}
ErrPasswordTooShort is returned when the password doesn't have enough characters.
func (ErrPasswordTooShort) Error ¶ added in v1.2.1
func (e ErrPasswordTooShort) Error() string
type ErrPasswordsDoNotMatch ¶ added in v1.2.1
type ErrPasswordsDoNotMatch struct { }
ErrPasswordsDoNotMatch is returned when the password doesn't match the confirmation.
func (ErrPasswordsDoNotMatch) Error ¶ added in v1.2.1
func (e ErrPasswordsDoNotMatch) Error() string
type ErrUnsupportedEncryption ¶ added in v1.2.1
type ErrUnsupportedEncryption struct {
Algorithm string
}
ErrUnsupportedEncryption is returned when the algorithm used is not supported.
func (ErrUnsupportedEncryption) Error ¶ added in v1.2.1
func (e ErrUnsupportedEncryption) Error() string
type ErrUnsupportedPrivateKeyFormat ¶ added in v1.2.1
type ErrUnsupportedPrivateKeyFormat struct {
Format string
}
ErrUnsupportedPrivateKeyFormat is returned when the format used is not supported.
func (ErrUnsupportedPrivateKeyFormat) Error ¶ added in v1.2.1
func (e ErrUnsupportedPrivateKeyFormat) Error() string
type ErrUnsupportedPrivateKeyType ¶ added in v1.2.1
type ErrUnsupportedPrivateKeyType struct {
Type string
}
ErrUnsupportedPrivateKeyType is returned when the type used is not supported.
func (ErrUnsupportedPrivateKeyType) Error ¶ added in v1.2.1
func (e ErrUnsupportedPrivateKeyType) Error() string
type ErrUnsupportedPublicKeyFormat ¶ added in v1.2.1
type ErrUnsupportedPublicKeyFormat struct {
Format string
}
ErrUnsupportedPublicKeyFormat is returned when the format used is not supported.
func (ErrUnsupportedPublicKeyFormat) Error ¶ added in v1.2.1
func (e ErrUnsupportedPublicKeyFormat) Error() string
type ErrUnsupportedPublicKeyType ¶ added in v1.2.1
type ErrUnsupportedPublicKeyType struct {
Type string
}
ErrUnsupportedPublicKeyType is returned when the type used is not supported.
func (ErrUnsupportedPublicKeyType) Error ¶ added in v1.2.1
func (e ErrUnsupportedPublicKeyType) Error() string
type ErrUnsupportedSignature ¶ added in v1.2.1
type ErrUnsupportedSignature struct {
Algorithm string
}
ErrUnsupportedSignature is returned when the algorithm used is not supported.
func (ErrUnsupportedSignature) Error ¶ added in v1.2.1
func (e ErrUnsupportedSignature) Error() string
type KeyShare ¶
type KeyShare struct {}
func (*KeyShare) Descriptor ¶
func (*KeyShare) GetPassword ¶
func (*KeyShare) GetPrivateFormat ¶
func (m *KeyShare) GetPrivateFormat() PrivateKeyFormat
func (*KeyShare) GetPrivateKey ¶
func (*KeyShare) GetPublicFormat ¶
func (m *KeyShare) GetPublicFormat() PublicKeyFormat
func (*KeyShare) GetPublicKey ¶
func (*KeyShare) ProtoMessage ¶
func (*KeyShare) ProtoMessage()
func (*KeyShare) XXX_DiscardUnknown ¶
func (m *KeyShare) XXX_DiscardUnknown()
func (*KeyShare) XXX_Marshal ¶
func (*KeyShare) XXX_Unmarshal ¶
type KeyShareStore ¶
type PrivateKeyFormat ¶
type PrivateKeyFormat int32
const ( PrivateKeyFormat_UNKNOWN_PRIVATE_KEY_FORMAT PrivateKeyFormat = 0 PrivateKeyFormat_PKCS1_PRIVATE PrivateKeyFormat = 1 PrivateKeyFormat_PKCS8 PrivateKeyFormat = 2 )
func (PrivateKeyFormat) EnumDescriptor ¶
func (PrivateKeyFormat) EnumDescriptor() ([]byte, []int)
func (PrivateKeyFormat) String ¶
func (x PrivateKeyFormat) String() string
type PublicKeyFormat ¶
type PublicKeyFormat int32
const ( PublicKeyFormat_UNKNOWN_PUBLIC_KEY_FORMAT PublicKeyFormat = 0 PublicKeyFormat_PKCS1_PUBLIC PublicKeyFormat = 1 PublicKeyFormat_PKIX PublicKeyFormat = 2 PublicKeyFormat_X509 PublicKeyFormat = 3 )
func (PublicKeyFormat) EnumDescriptor ¶
func (PublicKeyFormat) EnumDescriptor() ([]byte, []int)
func (PublicKeyFormat) String ¶
func (x PublicKeyFormat) String() string
type SignatureAlgorithm ¶
type SignatureAlgorithm int32
const ( SignatureAlgorithm_UNKNOWN_SIGNATURE SignatureAlgorithm = 0 SignatureAlgorithm_SHA512WITHRSA SignatureAlgorithm = 1 SignatureAlgorithm_SHA512WITHRSA_PSS SignatureAlgorithm = 2 )
func (SignatureAlgorithm) EnumDescriptor ¶
func (SignatureAlgorithm) EnumDescriptor() ([]byte, []int)
func (SignatureAlgorithm) String ¶
func (x SignatureAlgorithm) String() string