rsa2048

package
v0.0.0-...-ab467c6 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const BASEBITS uint = 58
View Source
const BIGBITS int = int(MODBYTES * 8)
View Source
const CHUNK int = 64 /* Set word size */
View Source
const DNLEN int = 2 * NLEN
View Source
const FFLEN int = 2

Modulus as number of BIGs

View Source
const FF_BITS int = (BIGBITS * FFLEN) /* Finite Field Size in bits - must be 256.2^n */

Modulus length in bits

View Source
const HBITS uint = (BASEBITS / 2)
View Source
const HFLEN int = (FFLEN / 2) /* Useful for half-size RSA private key operations */
View Source
const MODBYTES uint = 128

BIG length in bytes and number base

View Source
const NEXCESS int = (1 << (uint(CHUNK) - BASEBITS - 1))
View Source
const NLEN int = int((1 + ((8*MODBYTES - 1) / BASEBITS)))

BIG lengths and Masks

View Source
const P_MBITS uint = MODBYTES * 8
View Source
const P_TBITS uint = (P_MBITS % BASEBITS)
View Source
const RFS int = int(MODBYTES) * FFLEN
View Source
const RSA_HASH_TYPE int = core.SHA256

Variables

This section is empty.

Functions

func Comp

func Comp(a *BIG, b *BIG) int

Compare a and b, return 0 if a==b, -1 if a<b, +1 if a>b. Inputs must be normalised

func New_private_key

func New_private_key(n int) *rsa_private_key

func New_public_key

func New_public_key(m int) *rsa_public_key

func RSA_DECRYPT

func RSA_DECRYPT(PRIV *rsa_private_key, G []byte, F []byte)

RSA decryption with the private key

func RSA_ENCRYPT

func RSA_ENCRYPT(PUB *rsa_public_key, F []byte, G []byte)

RSA encryption with the public key

func RSA_KEY_PAIR

func RSA_KEY_PAIR(rng *core.RAND, e int, PRIV *rsa_private_key, PUB *rsa_public_key)

func RSA_KEY_PAIR_FROM_OPENSSL

func RSA_KEY_PAIR_FROM_OPENSSL(e int, P []byte, Q []byte, DP []byte, DQ []byte, C []byte, PRIV *rsa_private_key, PUB *rsa_public_key)

func RSA_PRIVATE_KEY_FROM_OPENSSL

func RSA_PRIVATE_KEY_FROM_OPENSSL(P []byte, Q []byte, DP []byte, DQ []byte, C []byte, PRIV *rsa_private_key)

Input private key from OpenSSL format e.g as in openssl rsa -in privkey.pem -noout -text Note order swap - For MIRACL c=1/p mod q, for OpenSSL c=1/q mod p

func RSA_PRIVATE_KEY_KILL

func RSA_PRIVATE_KEY_KILL(PRIV *rsa_private_key)

destroy the Private Key structure

Types

type BIG

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

func FromBytes

func FromBytes(b []byte) *BIG

func Modadd

func Modadd(a1, b1, m *BIG) *BIG

return a+b mod m

func Modmul

func Modmul(a1, b1, m *BIG) *BIG

return a*b mod m

func Modneg

func Modneg(a1, m *BIG) *BIG

return -a mod m

func Modsqr

func Modsqr(a1, m *BIG) *BIG

return a^2 mod m

func NewBIG

func NewBIG() *BIG

func NewBIGcopy

func NewBIGcopy(x *BIG) *BIG

func NewBIGdcopy

func NewBIGdcopy(x *DBIG) *BIG

func NewBIGint

func NewBIGint(x int) *BIG

func NewBIGints

func NewBIGints(x [NLEN]Chunk) *BIG

func Random

func Random(rng *core.RAND) *BIG

get 8*MODBYTES size random number

func Randomnum

func Randomnum(q *BIG, rng *core.RAND) *BIG

Create random BIG in portable way, one bit at a time

func Randtrunc

func Randtrunc(q *BIG, trunc int, rng *core.RAND) *BIG

func (*BIG) Invmodp

func (r *BIG) Invmodp(p *BIG)

this=1/this mod p. Binary method

func (*BIG) Jacobi

func (r *BIG) Jacobi(p *BIG) int

Jacobi Symbol (this/p). Returns 0, 1 or -1

func (*BIG) Minus

func (r *BIG) Minus(x *BIG) *BIG

return this-x

func (*BIG) Mod

func (r *BIG) Mod(m *BIG)

reduce this mod m

func (*BIG) Nbits

func (r *BIG) Nbits() int

func (*BIG) Plus

func (r *BIG) Plus(x *BIG) *BIG

return this+x

func (*BIG) Powmod

func (r *BIG) Powmod(e1 *BIG, m *BIG) *BIG

return this^e mod m

func (*BIG) ToBytes

func (r *BIG) ToBytes(b []byte)

func (*BIG) ToString

func (r *BIG) ToString() string

Convert to Hex String

type Chunk

type Chunk int64
const BMASK Chunk = ((Chunk(1) << BASEBITS) - 1)
const HMASK Chunk = ((Chunk(1) << HBITS) - 1)
const P_FEXCESS Chunk = (Chunk(1) << (BASEBITS*uint(NLEN) - P_MBITS - 1))
const P_OMASK Chunk = (Chunk(-1) << (P_MBITS % BASEBITS))

func FF_EXCESS

func FF_EXCESS(a *BIG) Chunk

type DBIG

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

func DBIG_fromBytes

func DBIG_fromBytes(b []byte) *DBIG

convert from byte array to BIG

func NewDBIG

func NewDBIG() *DBIG

func NewDBIGcopy

func NewDBIGcopy(x *DBIG) *DBIG

func NewDBIGscopy

func NewDBIGscopy(x *BIG) *DBIG

func (*DBIG) Mod

func (r *DBIG) Mod(m *BIG) *BIG

reduces this DBIG mod a BIG, and returns the BIG

type FF

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

func NewFFint

func NewFFint(n int) *FF

Constructors

Jump to

Keyboard shortcuts

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