Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)
- func CreateSignature(privateKey *rsa.PrivateKey, data []byte, algorithm SignatureAlgorithm) ([]byte, error)
- func DecryptAESGCM(key, encrypted []byte) ([]byte, error)
- func DecryptKey(algorithm EncryptionAlgorithm, secret []byte, key *rsa.PrivateKey) ([]byte, error)
- func DecryptPayload(algorithm EncryptionAlgorithm, key []byte, payload []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 GetOrCreateRSAPrivateKey(directory, name string) (*rsa.PrivateKey, error)
- func GetPassword() ([]byte, error)
- func GetRSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, 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 ParseRSAPrivateKey(privateKey []byte, format PrivateKeyFormat) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(publicKey []byte, format PublicKeyFormat) (*rsa.PublicKey, error)
- func PrivateKeyToRSAPrivateKey(key interface{}) (*rsa.PrivateKey, error)
- func PublicKeyToRSAPublicKey(key interface{}) (*rsa.PublicKey, 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(publicKey *rsa.PublicKey, data, signature []byte, algorithm SignatureAlgorithm) 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 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 ¶
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 ERROR_EXPORT = "Export error: %d %s" ERROR_PASSWORD_TOO_SHORT = "Password Too Short: %d Minimum: %d" ERROR_PASSWORDS_DO_NOT_MATCH = "Passwords Do Not Match" ERROR_UNSUPPORTED_ENCRYPTION = "Unsupported encryption: %s" ERROR_UNSUPPORTED_PUBLIC_KEY_TYPE = "Unsupported Public Key Type: %s" ERROR_UNSUPPORTED_PRIVATE_KEY_TYPE = "Unsupported Private Key Type: %s" ERROR_UNSUPPORTED_PUBLIC_KEY_FORMAT = "Unsupported Public Key Format: %s" ERROR_UNSUPPORTED_PRIVATE_KEY_FORMAT = "Unsupported Private Key Format: %s" ERROR_UNSUPPORTED_SIGNATURE = "Unsupported Signature Algorithm: %s" )
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(privateKey *rsa.PrivateKey, data []byte, algorithm SignatureAlgorithm) ([]byte, error)
func DecryptAESGCM ¶
func DecryptKey ¶
func DecryptKey(algorithm EncryptionAlgorithm, secret []byte, key *rsa.PrivateKey) ([]byte, error)
func DecryptPayload ¶
func DecryptPayload(algorithm EncryptionAlgorithm, key []byte, payload []byte) ([]byte, error)
func EncryptAESGCM ¶
func GenerateRandomKey ¶
func GetOrCreateRSAPrivateKey ¶
func GetOrCreateRSAPrivateKey(directory, name string) (*rsa.PrivateKey, error)
func GetPassword ¶
func GetRSAPrivateKey ¶
func GetRSAPrivateKey(directory, name string, password []byte) (*rsa.PrivateKey, error)
func HasRSAPrivateKey ¶
func ImportKeys ¶
func KeyShareHandler ¶
func KeyShareHandler(keys KeyShareStore, timeout time.Duration) func(w http.ResponseWriter, r *http.Request)
func ListRSAPrivateKeys ¶
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(privateKey []byte, format PrivateKeyFormat) (*rsa.PrivateKey, error)
func ParseRSAPublicKey ¶
func ParseRSAPublicKey(publicKey []byte, format PublicKeyFormat) (*rsa.PublicKey, error)
func PrivateKeyToRSAPrivateKey ¶
func PrivateKeyToRSAPrivateKey(key interface{}) (*rsa.PrivateKey, error)
func PublicKeyToRSAPublicKey ¶
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(publicKey *rsa.PublicKey, data, signature []byte, algorithm SignatureAlgorithm) 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 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
Click to show internal directories.
Click to hide internal directories.