crypto-srp-0.1.0.2: SRP authentication primitives
Copyright(c) 2025 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <adetokunbo@emio.la>
Safe HaskellSafe-Inferred
LanguageHaskell2010

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 ByteString encoding helpers.

Synopsis

the PrimeGroups

data PrimeGroup Source #

Represents the primeGroups used in SRP computations

Constructors

G1024 
G1536 
G2048 
G3072 
G4096 
G6144 
G8192 

Instances

Instances details
Show PrimeGroup Source # 
Instance details

Defined in Crypto.SRP.PrimeGroup

Eq PrimeGroup Source # 
Instance details

Defined in Crypto.SRP.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: length bs <= byteLength pg. If bs 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 #

Perform exponentiation modulus the large number in a PrimeGroup

Example

modExpPrime base power G2048

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