Documentation ¶
Index ¶
- func EncodeFMPPrivateKey(priv *FMPPrivateKey) string
- func EncodeFMPPublicKey(pub *FMPPublicKey) string
- func FMPtoBigPrivateKey(key *FMPPrivateKey) *x509big.BigPrivateKey
- func FMPtoBigPublicKey(key *FMPPublicKey) *x509big.BigPublicKey
- type CRTValue
- type FMPPrivateKey
- type FMPPublicKey
- type PrecomputedValues
- type RSA
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeFMPPrivateKey ¶
func EncodeFMPPrivateKey(priv *FMPPrivateKey) string
EncodeFMPPrivateKey marshalls an RSA private key using FMP types into a string.
func EncodeFMPPublicKey ¶
func EncodeFMPPublicKey(pub *FMPPublicKey) string
EncodeFMPPublicKey marshalls an RSA public key using FMP types into a string.
func FMPtoBigPrivateKey ¶
func FMPtoBigPrivateKey(key *FMPPrivateKey) *x509big.BigPrivateKey
FMPtoBigPrivateKey takes a FMPPrivateKey and returns an x509big.PrivateKey using native go big Int types.
func FMPtoBigPublicKey ¶
func FMPtoBigPublicKey(key *FMPPublicKey) *x509big.BigPublicKey
FMPtoBigPublicKey takes a FMPPublicKey and returns an x509big.PublicKey using native go big Int types.
Types ¶
type CRTValue ¶
type CRTValue struct { Exp *fmp.Fmpz // D mod (prime-1). Coeff *fmp.Fmpz // R·Coeff ≡ 1 mod Prime. R *fmp.Fmpz // product of primes prior to this (inc p and q). }
CRTValue contains the precomputed Chinese remainder theorem values.
type FMPPrivateKey ¶
type FMPPrivateKey struct { PublicKey *FMPPublicKey D *fmp.Fmpz Primes []*fmp.Fmpz N *fmp.Fmpz Precomputed *PrecomputedValues }
FMPPrivateKey represents a RSA private key using FMP data structures.
func BigtoFMPPrivateKey ¶
func BigtoFMPPrivateKey(key *x509big.BigPrivateKey) FMPPrivateKey
BigtoFMPPrivateKey takes a x509big.BigPrivateKey and returns a FMPPrivateKey that uses fmp.Fmpz types
func ImportKey ¶
func ImportKey(kb []byte) (*FMPPrivateKey, error)
ImportKey imports a PEM key file and returns a FMPPrivateKey object or error.
func PrivateFromPublic ¶
func PrivateFromPublic(key *FMPPublicKey) *FMPPrivateKey
PrivateFromPublic takes a Public Key and return a Private Key with the public components packed.
type FMPPublicKey ¶
FMPPublicKey represents a RSA public key using FMP data structures.
type PrecomputedValues ¶
type PrecomputedValues struct {
Dp, Dq *fmp.Fmpz // D mod (P-1) (or mod Q-1)
Qinv *fmp.Fmpz // Q^-1 mod P
// CRTValues is used for the 3rd and subsequent primes. Due to a
// historical accident, the CRT for the first two primes is handled
// differently in PKCS#1 and interoperability is sufficiently
// important that we mirror this.
CRTValues []CRTValue
}
PrecomputedValues contains precomputed values that speed up private operations, if available.
type RSA ¶
type RSA struct { Key FMPPrivateKey CipherText []byte PlainText []byte KnownPlainText []byte DLSB []byte OracleCiphertexts map[int]*fmp.Fmpz KeyFilename string PastPrimesFile string NumPrimes int Verbose bool Log *log.Logger }
RSA wraps FMPPrivateKey and adds a field for cipher and plaintexts.
func ImportIntegerList ¶
ImportIntegerList attempts to parse the key (and optionally ciphertext) data as if it was a list of integers N, and e and c.
func (*RSA) PackGivenD ¶
PackGivenD takes d and packs it into the key, solving for any ciphertext on the way.
func (*RSA) PackGivenP ¶
PackGivenP takes one prime p and packs the Key member of the RSA struct with the private key values, p, q & d as well as the Plaintext if a Ciphertext was given.
func (*RSA) PackMultiPrime ¶
PackMultiPrime takes many primes and packs the RSA struct with the private key values, []*Primes & d.