key
import "github.com/bloock/bloock-sdk-go/v2/entity/key"
Index
- Variables
- type AccessControl
- type AccessControlSecret
- type AccessControlTotp
- type AccessControlType
- type CertificateType
- type ImportCertificateParams
- type Key
- type KeyPair
- type KeyProtectionLevel
- type KeyType
- type LocalCertificate
- type LocalCertificateParams
- type LocalKey
- type Managed
- type ManagedCertificate
- type ManagedCertificateParams
- type ManagedKey
- type ManagedKeyParams
- type SubjectCertificateParams
- type TotpAccessControlReceipt
Variables
AccessControlTypeFromProto
var (
AccessControlTypeFromProto = map[proto.AccessControlType]AccessControlType{
proto.AccessControlType_NO_ACCESS_CONTROL: ACCESS_CONTROL_NONE,
proto.AccessControlType_TOTP: ACCESS_CONTROL_TOTP,
proto.AccessControlType_SECRET: ACCESS_CONTROL_SECRET,
}
AccessControlTypeToProto = map[AccessControlType]proto.AccessControlType{
ACCESS_CONTROL_NONE: proto.AccessControlType_NO_ACCESS_CONTROL,
ACCESS_CONTROL_TOTP: proto.AccessControlType_TOTP,
ACCESS_CONTROL_SECRET: proto.AccessControlType_SECRET,
}
)
CertificateTypeFromProto
var (
CertificateTypeFromProto = map[proto.CertificateType]CertificateType{
proto.CertificateType_PEM: PEM,
proto.CertificateType_PFX: PFX,
}
CertificateTypeToProto = map[CertificateType]proto.CertificateType{
PEM: proto.CertificateType_PEM,
PFX: proto.CertificateType_PFX,
}
)
KeyProtectionLevelFromProto
var (
KeyProtectionLevelFromProto = map[proto.KeyProtectionLevel]KeyProtectionLevel{
proto.KeyProtectionLevel_SOFTWARE: KEY_PROTECTION_SOFTWARE,
proto.KeyProtectionLevel_HSM: KEY_PROTECTION_HSM,
}
KeyProtectionLevelToProto = map[KeyProtectionLevel]proto.KeyProtectionLevel{
KEY_PROTECTION_SOFTWARE: proto.KeyProtectionLevel_SOFTWARE,
KEY_PROTECTION_HSM: proto.KeyProtectionLevel_HSM,
}
)
KeyTypeFromProto
var (
KeyTypeFromProto = map[proto.KeyType]KeyType{
proto.KeyType_EcP256k: EcP256k,
proto.KeyType_Rsa2048: Rsa2048,
proto.KeyType_Rsa3072: Rsa3072,
proto.KeyType_Rsa4096: Rsa4096,
proto.KeyType_Aes128: Aes128,
proto.KeyType_Aes256: Aes256,
proto.KeyType_Bjj: Bjj,
}
KeyTypeToProto = map[KeyType]proto.KeyType{
EcP256k: proto.KeyType_EcP256k,
Rsa2048: proto.KeyType_Rsa2048,
Rsa3072: proto.KeyType_Rsa3072,
Rsa4096: proto.KeyType_Rsa4096,
Aes128: proto.KeyType_Aes128,
Aes256: proto.KeyType_Aes256,
Bjj: proto.KeyType_Bjj,
}
)
AccessControl
type AccessControl
AccessControl represents access control information, including Time-based One-Time Password (TOTP) and secret-based access.
type AccessControl struct {
AccessControlTotp *AccessControlTotp
AccessControlSecret *AccessControlSecret
}
AccessControl.ToProto
func (AccessControl) ToProto
func (a AccessControl) ToProto() *proto.AccessControl
AccessControlSecret
type AccessControlSecret
AccessControlSecret represents a secret used for secret-based access control.
type AccessControlSecret struct {
Secret string
}
NewAccessControlSecret
func NewAccessControlSecret
func NewAccessControlSecret(secret string) *AccessControlSecret
NewAccessControlSecret creates a new AccessControlSecret instance with the provided secret.
AccessControlSecret.ToProto
func (AccessControlSecret) ToProto
func (a AccessControlSecret) ToProto() *proto.AccessControlSecret
AccessControlTotp
type AccessControlTotp
AccessControlTotp represents a Time-based One-Time Password (TOTP) code used for access control.
type AccessControlTotp struct {
Code string
}
NewAccessControlTotp
func NewAccessControlTotp
func NewAccessControlTotp(code string) *AccessControlTotp
NewAccessControlTotp creates a new AccessControlTotp instance with the provided TOTP code.
AccessControlTotp.ToProto
func (AccessControlTotp) ToProto
func (a AccessControlTotp) ToProto() *proto.AccessControlTotp
AccessControlType
type AccessControlType
AccessControlType represents the access control type of a key.
type AccessControlType int32
ACCESS_CONTROL_NONE
const (
// ACCESS_CONTROL_NONE indicates that the key is not protected by access control.
ACCESS_CONTROL_NONE AccessControlType = iota
// ACCESS_CONTROL_TOTP indicates that the key is protected by a TOTP-based access control.
ACCESS_CONTROL_TOTP AccessControlType = iota
// ACCESS_CONTROL_SECRET indicates that the key is protected by a SECRET-based access control.
ACCESS_CONTROL_SECRET AccessControlType = iota
)
CertificateType
type CertificateType
CertificateType represents the type of certificate.
type CertificateType int32
PEM
const (
// PEM is a certificate type.
PEM CertificateType = iota
// PFX is a certificate type.
PFX CertificateType = iota
)
ImportCertificateParams
type ImportCertificateParams
ImportCertificateParams represents parameters for importing a certificate.
type ImportCertificateParams struct {
Password string
}
NewImportCertificateParams
func NewImportCertificateParams
func NewImportCertificateParams() ImportCertificateParams
NewImportCertificateParams creates an ImportCertificateParams instance with default values.
Key
type Key
Key represents a key entity that can be either a ManagedKey or a LocalKey.
type Key struct {
LocalKey *LocalKey
ManagedKey *ManagedKey
}
Key.ToProto
func (Key) ToProto
func (s Key) ToProto() *proto.Key
KeyPair
type KeyPair
KeyPair represents a pair of public and private keys.
type KeyPair struct {
PublicKey string
PrivateKey string
}
NewEcdsaKeysFromProto
func NewEcdsaKeysFromProto
func NewEcdsaKeysFromProto(k *proto.GenerateLocalKeyResponse) KeyPair
NewRsaKeyPairFromProto
func NewRsaKeyPairFromProto
func NewRsaKeyPairFromProto(k *proto.GenerateLocalKeyResponse) KeyPair
KeyProtectionLevel
type KeyProtectionLevel
KeyProtectionLevel represents the protection level of a cryptographic key.
type KeyProtectionLevel int32
KEY_PROTECTION_SOFTWARE
const (
// KEY_PROTECTION_SOFTWARE indicates that the key is protected by software.
KEY_PROTECTION_SOFTWARE KeyProtectionLevel = iota
// KEY_PROTECTION_HSM indicates that the key is protected by a Hardware Security Module (HSM).
KEY_PROTECTION_HSM KeyProtectionLevel = iota
)
KeyType
type KeyType
KeyType represents the type of cryptographic key.
type KeyType int32
EcP256k
const (
// EcP256k represents the elliptic curve key type P-256k.
EcP256k KeyType = iota
// Rsa2048 represents the RSA key type with a 2048-bit modulus.
Rsa2048 KeyType = iota
// Rsa3072 represents the RSA key type with a 3072-bit modulus.
Rsa3072 KeyType = iota
// Rsa4096 represents the RSA key type with a 4096-bit modulus.
Rsa4096 KeyType = iota
// Aes128 represents the AES key type with a 128-bit key length.
Aes128 KeyType = iota
// Aes256 represents the AES key type with a 256-bit key length.
Aes256 KeyType = iota
// Bjj represents the Baby JubJub key type, elliptic curve defined over the large prime subgroup of BN128.
Bjj KeyType = iota
)
LocalCertificate
type LocalCertificate
LocalCertificate represents a local certificate along with its password.
type LocalCertificate struct {
Pkcs12 []byte
Password string
}
NewLocalCertificateFromProto
func NewLocalCertificateFromProto
func NewLocalCertificateFromProto(s *proto.LocalCertificate) LocalCertificate
LocalCertificate.ToProto
func (LocalCertificate) ToProto
func (s LocalCertificate) ToProto() *proto.LocalCertificate
LocalCertificateParams
type LocalCertificateParams
LocalCertificateParams represents the parameters for generating a local certificate.
type LocalCertificateParams struct {
KeyType KeyType
Password string
Subject SubjectCertificateParams
ExpirationMonths int32
}
NewLocalCertificateParamsFromProto
func NewLocalCertificateParamsFromProto
func NewLocalCertificateParamsFromProto(s *proto.LocalCertificateParams) LocalCertificateParams
LocalCertificateParams.ToProto
func (LocalCertificateParams) ToProto
func (s LocalCertificateParams) ToProto() *proto.LocalCertificateParams
LocalKey
type LocalKey
LocalKey represents a local key with its public and private components.
type LocalKey struct {
// Key is the public key.
Key string
// PrivateKey is the private key.
PrivateKey string
// KeyType is the type of the key.
KeyType KeyType
}
NewLocalKeyFromProto
func NewLocalKeyFromProto
func NewLocalKeyFromProto(s *proto.LocalKey) LocalKey
LocalKey.ToProto
func (LocalKey) ToProto
func (s LocalKey) ToProto() *proto.LocalKey
Managed
type Managed
Managed represents a managed entity that can be either a ManagedKey or a ManagedCertificate.
type Managed struct {
ManagedKey *ManagedKey
ManagedCertificate *ManagedCertificate
}
ManagedCertificate
type ManagedCertificate
ManagedCertificate represents a managed certificate with its details.
type ManagedCertificate struct {
// ID is the identifier of the managed certificate (ex: 2abae00b-f3d9-410c-abdf-1ea391d633aa).
ID string
// Protection is the protection level for the key.
Protection KeyProtectionLevel
// KeyType is the type of the key.
KeyType KeyType
// Expiration is the timestamp indicating when the certificate expires.
Expiration int64
// Key is the certificate public key.
Key string
// AccessControlType is the access control type for the key.
AccessControlType AccessControlType
}
NewManagedCertificateFromProto
func NewManagedCertificateFromProto
func NewManagedCertificateFromProto(s *proto.ManagedCertificate) ManagedCertificate
ManagedCertificate.ToProto
func (ManagedCertificate) ToProto
func (s ManagedCertificate) ToProto() *proto.ManagedCertificate
ManagedCertificateParams
type ManagedCertificateParams
ManagedCertificateParams represents parameters for creating a managed certificate.
type ManagedCertificateParams struct {
// KeyType is the type of the key.
KeyType KeyType
// Subject represents the subject details of the certificate.
Subject SubjectCertificateParams
// ExpirationMonths is the number of months until the certificate expiration.
ExpirationMonths int32
}
NewManagedCertificateParamsFromProto
func NewManagedCertificateParamsFromProto
func NewManagedCertificateParamsFromProto(s *proto.ManagedCertificateParams) ManagedCertificateParams
ManagedCertificateParams.ToProto
func (ManagedCertificateParams) ToProto
func (s ManagedCertificateParams) ToProto() *proto.ManagedCertificateParams
ManagedKey
type ManagedKey
ManagedKey represents a managed key.
type ManagedKey struct {
// ID is the unique identifier of the managed key (ex: 46c49ee7-ef44-472c-a873-ce81a2d5d764).
ID string
// Name is the name of the managed key.
Name string
// Protection is the protection level for the key.
Protection KeyProtectionLevel
// KeyType is the type of the key.
KeyType KeyType
// Expiration is the timestamp indicating when the key expires.
Expiration int64
// Key is the actual public key.
Key string
// AccessControlType is the access control type for the key.
AccessControlType AccessControlType
}
NewManagedKeyFromProto
func NewManagedKeyFromProto
func NewManagedKeyFromProto(s *proto.ManagedKey) ManagedKey
ManagedKey.ToProto
func (ManagedKey) ToProto
func (s ManagedKey) ToProto() *proto.ManagedKey
ManagedKey.Type
func (ManagedKey) Type
func (s ManagedKey) Type() KeyType
ManagedKeyParams
type ManagedKeyParams
ManagedKeyParams represents the parameters for creating a managed key.
type ManagedKeyParams struct {
// Name is the name of the managed key.
Name string
// Protection is the protection level for the key.
Protection KeyProtectionLevel
// KeyType is the type of the key.
KeyType KeyType
// Expiration is the timestamp indicating when the key expires.
Expiration int64
}
NewManagedKeyParamsFromProto
func NewManagedKeyParamsFromProto
func NewManagedKeyParamsFromProto(s *proto.ManagedKeyParams) ManagedKeyParams
ManagedKeyParams.ToProto
func (ManagedKeyParams) ToProto
func (s ManagedKeyParams) ToProto() *proto.ManagedKeyParams
SubjectCertificateParams
type SubjectCertificateParams
SubjectCertificateParams represents parameters for generating a subject certificate.
type SubjectCertificateParams struct {
// CommonName is the common name (CN) for the certificate. Required.
CommonName string
// Organization is the organization (O) for the certificate. (Optional)
Organization *string
// OrganizationUnit is the organizational unit (OU) for the certificate. (Optional)
OrganizationUnit *string
// Location is the location (L) for the certificate. (Optional)
Location *string
// State is the state or province (ST) for the certificate. (Optional)
State *string
// Country is the country (C) for the certificate. (Optional)
Country *string
}
TotpAccessControlReceipt
type TotpAccessControlReceipt
TotpAccessControlReceipt represents a receipt for a Time-based One-Time Password (TOTP) access control.
type TotpAccessControlReceipt struct {
Secret string
SecretQr string
RecoveryCodes []string
}
New
func New
func New(secret, secretQr string, recoveryCodes []string) TotpAccessControlReceipt
New creates a new TotpAccessControlReceipt with the provided secret, secret QR code, and recovery codes.
Generated by gomarkdoc