cryptoutils

package module
v0.0.0-...-e06ca9c Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cryptoutils provides a set of methods / functions to simplify typical flows concerning cryptographic operations

Index

Constants

View Source
const (
	Bits2048 = 2048
	Bits4096 = 4096
	Bits8192 = 8192
)

Provide various common key sizes

Variables

This section is empty.

Functions

This section is empty.

Types

type Bits

type Bits = int

Bits denotes the number of bits used for key creation / generation

type RSA

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

RSA denotes an RSA public / private key pair

func New

func New(bits Bits) (obj *RSA, err error)

New creates a new elliptic curve key pair

func NewFromPEM

func NewFromPEM(privPEM *pem.Block) (obj *RSA, err error)

NewFromPEM reads a private key from a PEM block

func NewFromString

func NewFromString(str string) (obj *RSA, err error)

NewFromString reads a private key / RSA object from a base64 encoded string

func (*RSA) Decrypt

func (e *RSA) Decrypt(cipherMsg []byte, h hash.Hash) ([]byte, error)

Decrypt decrypts a message using RSA-OAEP, using the hash h (falling back to sha256 if nil)

func (*RSA) Encrypt

func (e *RSA) Encrypt(clearMsg []byte, h hash.Hash) ([]byte, error)

Encrypt encrypts a message using RSA-OAEP, using the hash h (falling back to sha256 if nil)

func (*RSA) PrivKey

func (e *RSA) PrivKey() *rsa.PrivateKey

PrivKey returns the private key

func (*RSA) PrivKeyPEM

func (e *RSA) PrivKeyPEM() *pem.Block

PrivKeyPEM returns the private key as PEM block

func (*RSA) PrivKeyString

func (e *RSA) PrivKeyString() string

PrivKeyString returns the private key as base64 encoded PEM block

func (*RSA) PubKey

func (e *RSA) PubKey() *rsa.PublicKey

PubKey returns the public key

func (*RSA) PubKeyPEM

func (e *RSA) PubKeyPEM() *pem.Block

PubKeyPEM returns the public key as PEM block

Jump to

Keyboard shortcuts

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