Documentation ¶
Index ¶
- Variables
- func DecryptOAEP(hash hash.Hash, pub PublicKey, ciphertext []byte, label []byte) ([]byte, error)
- func EncryptOAEP(hash hash.Hash, random io.Reader, priv PrivateKey, msg []byte, label []byte) ([]byte, error)
- func GetMaxPayloadSize(hash hash.Hash, key PublicKey) int
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ErrDecryption = errors.New("xx_network/crypto/multicastRSA: " +
"decryption error")
ErrDecryption represents a failure to decrypt a message. It is deliberately vague to avoid adaptive attacks.
var ErrMessageTooLong = errors.New("xx_network/crypto/multicastRSA: " +
"message too long for RSA public key size")
ErrMessageTooLong is returned when attempting to encrypt a message which is too large for the size of the public key.
var ErrVerification = errors.New("xx_network/crypto/multicastRSA: " +
"verification error")
ErrVerification represents a failure to verify a signature. It is deliberately vague to avoid adaptive attacks.
Functions ¶
func DecryptOAEP ¶
DecryptOAEP decrypts ciphertext using RSA-OAEP using an RSA Public Key for multicast RSA.
OAEP is parameterised by a hash function that is used as a random oracle. Encryption and decryption of a given message must use the same hash function and sha256.New() is a reasonable choice.
The label parameter must match the value given when encrypting. See EncryptOAEP for details.
func EncryptOAEP ¶
func EncryptOAEP(hash hash.Hash, random io.Reader, priv PrivateKey, msg []byte, label []byte) ([]byte, error)
EncryptOAEP encrypts the given message with RSA-OAEP using a Private Key for multicast RSA.
OAEP is parameterised by a hash function that is used as a random oracle. Encryption and decryption of a given message must use the same hash function and sha256.New() is a reasonable choice.
The random parameter is used as a source of entropy to ensure that encrypting the same message twice doesn't result in the same ciphertext.
The label parameter may contain arbitrary data that will not be encrypted, but which gives important context to the message. For example, if a given public key is used to encrypt two types of messages then distinct label values could be used to ensure that a ciphertext for one purpose cannot be used for another by an attacker. If not required it can be empty.
The message must be no longer than the length of the public modulus minus twice the hash length, minus a further 2.
Types ¶
type PrivateKey ¶
type PrivateKey interface { // Private implements the same interface as public, but with // more functions. PublicKey // GetPrimes returns the prime factors of N, which has >= 2 elements GetPrimes() []*large.Int // GetD returns the private exponent of the RSA Private Key as // a large.Int GetD() *large.Int // GetDp returns D mod (P - 1), or nil if unavailable GetDp() *large.Int // GetDq returns D mod (Q - 1), or nil if unavailable GetDq() *large.Int }