| Copyright | (c) 2025 Tim Emiola |
|---|---|
| License | BSD3 |
| Maintainer | Tim Emiola <adetokunbo@emio.la> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Crypto.SRP.PrimeGroup
Description
Provides the PrimeGroup type representing the standard SRP prime groups
(1024–8192 bits) and the group-arithmetic operations used during the SRP
handshake: public key generation (pubOf), modular exponentiation
(modExpPrime), and encoding helpers.ByteString
Synopsis
- data PrimeGroup
- generatorFor :: PrimeGroup -> Word8
- safePrimeFor :: PrimeGroup -> Integer
- asByteString :: PrimeGroup -> ByteString
- hexLength :: PrimeGroup -> Int
- byteLength :: PrimeGroup -> Int
- pubOf :: Integer -> PrimeGroup -> Integer
- padAs :: ByteString -> PrimeGroup -> ByteString
- primeMod :: Integer -> PrimeGroup -> Integer
- modExpPrime :: Integer -> Integer -> PrimeGroup -> Integer
- bytesOf :: Natural -> ByteString
- fromBytes :: ByteString -> Integer
the PrimeGroups
data PrimeGroup Source #
Represents the primeGroups used in SRP computations
Instances
| Show PrimeGroup Source # | |
Defined in Crypto.SRP.PrimeGroup Methods showsPrec :: Int -> PrimeGroup -> ShowS # show :: PrimeGroup -> String # showList :: [PrimeGroup] -> ShowS # | |
| Eq PrimeGroup Source # | |
Defined in Crypto.SRP.PrimeGroup | |
generatorFor :: PrimeGroup -> Word8 Source #
The generator for PrimeGroup
safePrimeFor :: PrimeGroup -> Integer Source #
The safe prime for PrimeGroup
asByteString :: PrimeGroup -> ByteString Source #
A ByteString representing the safe prime in hexadecimal
hexLength :: PrimeGroup -> Int Source #
The number of hex characters in the representation of the safe prime
byteLength :: PrimeGroup -> Int Source #
The number of bytes in the binary encoding of the safe prime
pubOf :: Integer -> PrimeGroup -> Integer Source #
Generate the public version of a private ephemeral key
the private version of the key is expected to be a randomly generated integer
padAs :: ByteString -> PrimeGroup -> ByteString Source #
Pad a ByteString to the binary byte length of the safe prime of a
PrimeGroup, prepending zero bytes as needed.
Precondition: . If length bs <= byteLength pgbs is longer than the
group's byte length, no truncation occurs — the input is returned unchanged.
primeMod :: Integer -> PrimeGroup -> Integer Source #
Reduce an Integer modulo the safe prime of a PrimeGroup
modExpPrime :: Integer -> Integer -> PrimeGroup -> Integer Source #
SRP Integer <=> ByteString interconversion
bytesOf :: Natural -> ByteString Source #
Encode a Natural number as a ByteString
fromBytes :: ByteString -> Integer Source #
Obtain an Integer from its ByteString encoding