secrets

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package secrets provides RSA codec to work with Calyptia Cloud pipeline secrets.

Index

Constants

View Source
const (
	DefaultEncryptionBits = 2048
)

Variables

This section is empty.

Functions

func BytesToPrivateKey

func BytesToPrivateKey(privateKey []byte) (*rsa.PrivateKey, error)

func BytesToPublicKey

func BytesToPublicKey(publicKey []byte) (*rsa.PublicKey, error)

func Decrypt added in v1.2.0

func Decrypt(hash hash.Hash, privateKey *rsa.PrivateKey, msg []byte) ([]byte, error)

Decrypt decrypts the given ciphertext using RSA-OAEP with the given private key.

The ciphertext is split into chunks of size k, where k is the size of the private key in bytes. Each chunk is decrypted separately and the resulting plaintexts are concatenated.

At the end it returns the plaintext decrypted.

func Encrypt added in v1.2.0

func Encrypt(hash hash.Hash, publicKey *rsa.PublicKey, msg []byte) ([]byte, error)

Encrypt encrypts the given message using RSA-OAEP with the given public key.

The message is split into chunks of size k - 2*hLen - 2, where k is the size of the public key in bytes and hLen is the length of the hash function used. Each chunk is encrypted separately and the resulting ciphertexts are concatenated.

At the end it returns the ciphertext encrypted.

func PrivateKeyToBytes

func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte

func PublicKeyToBytes

func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)

Types

type RSA

type RSA struct {
	Bits int
}

func NewRSAHandler

func NewRSAHandler(bits int) *RSA

func (*RSA) DecryptWithPrivateKey

func (r *RSA) DecryptWithPrivateKey(msg, key []byte) ([]byte, error)

func (*RSA) EncryptWithPublicKey

func (r *RSA) EncryptWithPublicKey(msg, key []byte) ([]byte, error)

func (*RSA) GenerateKeyPair

func (r *RSA) GenerateKeyPair() (priv, pub []byte, err error)

Jump to

Keyboard shortcuts

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