rsa

package
v0.0.0-...-5e5dd25 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NAME - human-readable name of this Crypto implementation
	NAME = "RSA-4096,AES-CBC-256,HMAC-SHA-256"
)

Functions

This section is empty.

Types

type KeyPair

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

KeyPair for RSA : Bencrypt Implementation of a RSA-4096,AES-CBC-256,HMAC-SHA-256 system

func (*KeyPair) Clone

func (r *KeyPair) Clone() bc.KeyPair

Clone : Returns a new node of the same type as this one

func (*KeyPair) DecryptMessage

func (r *KeyPair) DecryptMessage(data []byte) (bool, []byte, error)

DecryptMessage : Decrypts a message 1) PEM decode header and body 2) decrypt header 3) verify the header signature 4) verify the msg signature 5) decrypt the msg

func (*KeyPair) EncryptMessage

func (r *KeyPair) EncryptMessage(clear []byte, pubkey bc.PubKey) ([]byte, error)

EncryptMessage : Encrypts a message

  1. generate aes key (32 random bytes)
  2. encrypt the message with aes key
  3. sha256 the encrypted message
  4. sha256 the key and msg hash
  5. encrypt the header with rsa
  6. PEM encode encrypted header and encrypted message -> return

func (*KeyPair) FromB64

func (r *KeyPair) FromB64(s string) error

FromB64 : Sets the private portion of this keypair from a Base64-encoded string

func (*KeyPair) GenerateKey

func (r *KeyPair) GenerateKey()

GenerateKey : Generates a new keypair inside this KeyPair object

func (*KeyPair) GetName

func (r *KeyPair) GetName() string

GetName : Returns the common language name for this cryptosystem

func (*KeyPair) GetPubKey

func (r *KeyPair) GetPubKey() bc.PubKey

GetPubKey : Returns the Public portion of this KeyPair

func (*KeyPair) Precompute

func (r *KeyPair) Precompute()

Precompute : Precomputes key

func (*KeyPair) ToB64

func (r *KeyPair) ToB64() string

ToB64 : Returns the private portion of this keypair as a Base64-encoded string

func (*KeyPair) ValidatePubKey

func (r *KeyPair) ValidatePubKey(s string) bool

ValidatePubKey : Returns true if and only if the argument is a valid PubKey to this KeyPair

type PubKey

type PubKey struct {
	Pubkey *rsa.PublicKey
}

PubKey : Implements bc.PubKey interface

func (*PubKey) Clone

func (e *PubKey) Clone() bc.PubKey

Clone : Returns a new PubKey of the same type as this one

func (*PubKey) FromB64

func (e *PubKey) FromB64(s string) error

FromB64 : Sets Public Key from a Base64 encoded string

func (*PubKey) FromBytes

func (e *PubKey) FromBytes(b []byte) error

FromBytes : Sets Public Key from bytes (PEM text)

func (*PubKey) Nil

func (e *PubKey) Nil() interface{}

Nil : Returns the interface-to-nil-pointer type for this PubKey

func (*PubKey) ToB64

func (e *PubKey) ToB64() string

ToB64 : Returns Public Key as a Base64 encoded string

func (*PubKey) ToBytes

func (e *PubKey) ToBytes() []byte

ToBytes : Returns Public Key as bytes (PEM text)

Jump to

Keyboard shortcuts

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