java.lang.Object
java.lang.Enum<NoiseInit.PatternID>
com.southernstorm.noise.protocol.NoiseInit.PatternID
All Implemented Interfaces:
Serializable, Comparable<NoiseInit.PatternID>, java.lang.constant.Constable
Enclosing class:
NoiseInit

public static enum NoiseInit.PatternIDextends Enum<NoiseInit.PatternID>
Pattern identifiers for Noise protocol handshake patterns.
  • Enum Constant Details

  • Field Details

    • prefix

      private final String prefix
      The name prefix of the pattern.
    • patternId

      private final String patternId
      The name identifying the pattern.
    • protoName

      private final String protoName
      The protocol name for the handshake.
    • dh

      private final String dh
      The Diffie-Hellman cipher name.
    • scipher

      private final String scipher
      The symmetric cipher name.
    • shash

      private final String shash
      The hash algorithm name.
    • pattern

      private short[] pattern
      The token list of the pattern.
    • ck

      private final byte[] ck
      The initial chaining key.
    • h

      private final byte[] h
      The initial handshake hash.
  • Constructor Details

    • PatternID

      private PatternID(String pid, String protocolName)
      Parse the protocol name into its components, validate, lookup the Pattern, and generate initial CK and H
      Parameters:
      pid - the pattern ID to look up, e.g. "XX"
      protocolName - the protocol name, five components separated by "_"
  • Method Details

    • values

      public static NoiseInit.PatternID[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NoiseInit.PatternID valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getPrefix

      public String getPrefix()
      Reports whether this is the Noise or NoisePSK family.
      Returns:
      the noise protocol family prefix, "Noise" or "NoisePSK"
    • getPatternID

      public String getPatternID()
      Reports which handshake pattern this protocol name selected.
      Returns:
      the pattern name as it appeared in the protocol name, e.g. "XX" or "XK"
    • getProtocolName

      public String getProtocolName()
      Reports the full protocol name this entry was parsed from.
      Returns:
      the full underscore-separated protocol name, e.g. "Noise_XKaes2gcm"
    • getDH

      public String getDH()
      Reports which Diffie-Hellman method this protocol uses.
      Returns:
      the Diffie-Hellman method named by the protocol name, e.g. "25519" or "MLKEM768"
    • getCipher

      public String getCipher()
      Reports which AEAD cipher this protocol uses.
      Returns:
      the AEAD cipher named by the protocol name, e.g. "chacha20poly1305"
    • getHash

      public String getHash()
      Reports which hash function this protocol uses.
      Returns:
      the hash function named by the protocol name, e.g. "SHA256" or "SHA512"
    • getPattern

      public short[] getPattern()
      Reports the message and flag tokens of the handshake pattern.
      Returns:
      the message and flag tokens making up the handshake pattern
    • getInitialCK

      public byte[] getInitialCK()
      The chaining key every handshake of this pattern starts from, made by hashing the protocol name. Returned as a copy so a restarted handshake cannot corrupt the state this pattern holds for the next one.
      Returns:
      a fresh copy of the pattern's initial chaining key, which the caller may mix into without disturbing this pattern
    • getInitialH

      public byte[] getInitialH()
      The hash of the initial chaining key: the value the handshake's hash chain starts from, before any handshake message is mixed in. Returned as a copy so a restarted handshake cannot corrupt this pattern's state.
      Returns:
      a fresh copy of the pattern's initial handshake hash, which the caller may mix into without disturbing this pattern
    • byPatternId

      public static NoiseInit.PatternID byPatternId(String pid)
      Lookup PatternID by string pattern ID
      Parameters:
      pid - the pattern name to look up, e.g. "XK"
      Returns:
      the enum constant whose pattern name equals pid
      Throws:
      IllegalArgumentException - if not found