Group

public enum Group

SRP Group Parameters

The 1024-, 1536-, and 2048-bit groups are taken from software developed by Tom Wu and Eugene Jhong for the Stanford SRP distribution, and subsequently proven to be prime. The larger primes are taken from [MODP], but generators have been calculated that are primitive roots of N, unlike the generators in [MODP].

The values of N and g used in this protocol must be agreed upon by the two parties in question. They can be set in advance, or the host can supply them to the client. In the latter case, the host should send the parameters in the first message along with the salt. For maximum security, N should be a safe prime (i.e. a number of the form N = 2q + 1, where q is also prime). Also, g should be a generator modulo N (see [SRP] for details), which means that for any X where 0 < X < N, there exists a value x for which g^x % N == X.

[MODP] Kivinen, T. and M. Kojo, “More Modular Exponentiation (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)”, RFC 3526, May 2003.

[SRP] T. Wu, “The Secure Remote Password Protocol”, In Proceedings of the 1998 Internet Society Symposium on Network and Distributed Systems Security, San Diego, CA, pp. 97-111.

  • 1024-bits group

    Declaration

    Swift

    case N1024
  • 2048-bits group

    Declaration

    Swift

    case N2048
  • 1536-bits group

    Declaration

    Swift

    case N1536
  • 3072-bits group

    Declaration

    Swift

    case N3072
  • 4096-bits group

    Declaration

    Swift

    case N4096
  • 6144-bits group

    Declaration

    Swift

    case N6144
  • 8192-bits group

    Declaration

    Swift

    case N8192
  • Custom group parameters. See init(prime:generator:) for more information.

    See more

    Declaration

    Swift

    public struct CustomGroup
  • Custom group parameters. See init(prime:generator:) for more information.

    Declaration

    Swift

    case custom(CustomGroup)
  • Create custom group parameters. See the enum’s documentation for considerations on good parameters.

    Declaration

    Swift

    public init?(prime: String, generator: String)

    Parameters

    prime

    hex-encoded prime

    generator

    hex-encoded generator

    Return Value

    nil if one of the parameters chould not be decoded

  • N

    Undocumented

    Declaration

    Swift

    var N: BigUInt { get }
  • g

    Undocumented

    Declaration

    Swift

    var g: BigUInt { get }