HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

Modulecrypton-2.1.7Haskell2010

Crypto.PubKey.RSA.Types

  • 5 types
  • 5 values
  • Packagecrypton-2.1.7
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause AND MIT AND ISC
  • SourceTypes.hs
datadata Error
#

error possible during encryption, decryption or signing.

Constructors

Instances2Eq, Show
  • Eq ErrorDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • Show ErrorDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
datadata Blinder
#

A blinder, which keeps the timing of the private key operation from saying anything about the number it was given.

The private exponent is not what is at risk. expSafe, which the exponentiation goes through, keeps the value of an exponent out of the work it does.

What a blinder covers is the other side. Without one, the operation runs on the ciphertext as it arrived, so how long it takes depends on a number an attacker may have chosen and can vary -- which is what a remote timing attack on RSA needs. With one, the input is multiplied by a random value first and that value divided out afterwards, so the timing carries nothing an attacker can steer.

Every private key operation here takes a Maybe Blinder. The Safer form of each -- decryptSafer, signSafer and their kind -- generates one and is the one to reach for. Pass Nothing only where the input is not attacker controlled and you have decided that it is not.

A blinder costs one more exponentiation, by the public exponent, which is the cheap direction: measured on an Apple M4, PKCS#1 v1.5 signing goes from about 601 to about 620 microseconds.

Use a blinder once. generateBlinder makes a fresh one; carrying one across operations is not what it is for.

Constructors

Instances2Eq, Show
  • Eq BlinderDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • Show BlinderDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
datadata PublicKey
#

Represent a RSA public key

Constructors

Instances7Eq, Data, Read, Show, Generic, NFData, …
datadata PrivateKey
#

Represent a RSA private key.

Only the pub, d fields are mandatory to fill.

p, q, dP, dQ, qinv are by-product during RSA generation, but are useful to record here to speed up massively the decrypt and sign operation.

implementations can leave optional fields to 0.

Constructors

Instances8Eq, Data, Read, Show, Generic, NFData, …
newtypenewtype KeyPair
#

Represent RSA KeyPair

note the RSA private key contains already an instance of public key for efficiency

Constructors

Instances6Eq, Data, Read, Show, NFData, DebugShow
  • Eq KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • Data KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • Read KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • Show KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • NFData KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types
  • DebugShow KeyPairDefined in crypton-2.1.7 · Crypto.PubKey.RSA.Types