asymkey

package
v0.0.0-...-a5ef9a9 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorPrivateKeyDecodeUnknownKeyType is returned when a decoded private key is of an invalid type
	ErrorPrivateKeyDecodeUnknownKeyType = utils.NewSealdError("ASYMKEY_PRIVATE_KEY_DECODE_UNKNOWN_KEY_TYPE", "PrivateKeyDecode: unknown key type")
	// ErrorGenerateInvalidSize is returned when an invalid key size is given at key generation
	ErrorGenerateInvalidSize = utils.NewSealdError("ASYMKEY_GENERATE_INVALID_SIZE", "Cannot generate a Private Key of given bit length. Acceptable values are 1024, 2049 and 4096")
	// ErrorUnmarshalBSONValueTooShort is returned when trying to unmarshal a bson that is too short
	ErrorUnmarshalBSONValueTooShort = utils.NewSealdError("ASYMKEY_UNMARSHALL_BSON_VALUE_TOO_SHORT", "Cannot unmarshal, not enough bytes")
	// ErrorUnmarshalBSONValueInvalidType is returned when trying to unmarshal a bson that is not a string
	ErrorUnmarshalBSONValueInvalidType = utils.NewSealdError("ASYMKEY_UNMARSHALL_BSON_VALUE_INVALID_TYPE", "Cannot unmarshal, type is not String")
	// ErrorDecryptCryptoRSA is returned when an error happen during decryption
	ErrorDecryptCryptoRSA = utils.NewSealdError("ASYMKEY_DECRYPT_CRYPTO_ERROR", "Cannot decrypt")
	// ErrorPublicKeyDecodeUnknownKeyType is returned when a decoded public key is of an invalid type
	ErrorPublicKeyDecodeUnknownKeyType = utils.NewSealdError("ASYMKEY_PUBLIC_KEY_DECODE_UNKNOWN_KEY_TYPE", "PublicKeyDecode: unknown key type")
)

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func Generate

func Generate(bits int) (*PrivateKey, error)

func PrivateKeyDecode

func PrivateKeyDecode(key []byte) (*PrivateKey, error)

func PrivateKeyDecodePKCS1DER

func PrivateKeyDecodePKCS1DER(key []byte) (*PrivateKey, error)

func PrivateKeyFromB64

func PrivateKeyFromB64(b64 string) (*PrivateKey, error)

func (*PrivateKey) BitLen

func (k *PrivateKey) BitLen() int

func (*PrivateKey) Decrypt

func (k *PrivateKey) Decrypt(encryptedMessage []byte) ([]byte, error)

func (*PrivateKey) Encode

func (k *PrivateKey) Encode() []byte

func (*PrivateKey) EncodePKCS1DER

func (k *PrivateKey) EncodePKCS1DER() []byte

func (*PrivateKey) MarshalBSONValue

func (k *PrivateKey) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*PrivateKey) MarshalJSON

func (k *PrivateKey) MarshalJSON() ([]byte, error)

func (*PrivateKey) Public

func (k *PrivateKey) Public() *PublicKey

func (*PrivateKey) Sign

func (k *PrivateKey) Sign(message []byte) ([]byte, error)

func (*PrivateKey) ToB64

func (k *PrivateKey) ToB64() string

func (*PrivateKey) UnmarshalBSONValue

func (k *PrivateKey) UnmarshalBSONValue(t bsontype.Type, bu []byte) error

func (*PrivateKey) UnmarshalJSON

func (k *PrivateKey) UnmarshalJSON(b []byte) error

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func PublicKeyDecode

func PublicKeyDecode(key []byte) (*PublicKey, error)

func PublicKeyFromB64

func PublicKeyFromB64(b64 string) (*PublicKey, error)

func (*PublicKey) BitLen

func (k *PublicKey) BitLen() int

func (*PublicKey) Encode

func (k *PublicKey) Encode() []byte

func (*PublicKey) Encrypt

func (k *PublicKey) Encrypt(message []byte) ([]byte, error)

func (*PublicKey) GetHash

func (k *PublicKey) GetHash() string

func (*PublicKey) MarshalJSON

func (k *PublicKey) MarshalJSON() ([]byte, error)

func (*PublicKey) ToB64

func (k *PublicKey) ToB64() string

func (*PublicKey) UnmarshalJSON

func (k *PublicKey) UnmarshalJSON(b []byte) error

func (*PublicKey) Verify

func (k *PublicKey) Verify(message, signature []byte) error

Jump to

Keyboard shortcuts

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