Package anbxj

Class Crypto_HmacPair

java.lang.Object
anbxj.Crypto_HmacPair
All Implemented Interfaces:
Serializable

public class Crypto_HmacPair extends Object implements Serializable
A class to store the result of an HMAC operation along with metadata about the used algorithm. Moreover, it allows carrying information for AnBx private or public digests.
See Also:
  • Constructor Details

    • Crypto_HmacPair

      public Crypto_HmacPair(Crypto_ByteArray hashValue, Crypto_SealedPair k, String HMacAlgorithm)
      Constructs a Crypto_HmacPair with the specified parameters.
      Parameters:
      hashValue - The hash value.
      k - The sealed pair.
      HMacAlgorithm - The HMAC algorithm.
    • Crypto_HmacPair

      public Crypto_HmacPair(Crypto_ByteArray hashValue, SecretKey sk, String HMacAlgorithm)
      Constructs a Crypto_HmacPair with the specified parameters.
      Parameters:
      hashValue - The hash value.
      sk - The secret key.
      HMacAlgorithm - The HMAC algorithm.
  • Method Details

    • getHashValue

      public Crypto_ByteArray getHashValue()
      Gets the hash value.
      Returns:
      The hash value.
    • getK

      public Crypto_SealedPair getK()
      Gets the sealed pair.
      Returns:
      The sealed pair.
    • getSK

      public SecretKey getSK()
      Gets the secret key.
      Returns:
      The secret key.
    • getAlgorithm

      public String getAlgorithm()
      Gets the HMAC algorithm.
      Returns:
      The HMAC algorithm.
    • anonymize

      public void anonymize()
      Anonymizes the HMAC pair by removing the public secret key.
    • toByteArray

      public byte[] toByteArray() throws IOException
      Serializes this Crypto_HmacPair into a byte array using standard Java object serialization, delegating to Crypto_SerializationUtils.serialize(Object).
      Returns:
      the serialized bytes
      Throws:
      IOException - if an I/O error occurs during serialization
    • fromByteArray

      public static Crypto_HmacPair fromByteArray(byte[] data) throws IOException, ClassNotFoundException
      Deserializes a Crypto_HmacPair from a byte array, delegating to Crypto_SerializationUtils.deserialize(byte[]).
      Parameters:
      data - the bytes produced by toByteArray()
      Returns:
      the reconstructed Crypto_HmacPair
      Throws:
      IOException - if an I/O error occurs during deserialization
      ClassNotFoundException - if the class of the serialized object cannot be found
    • toString

      public String toString()
      Returns a string representation of the Crypto_HmacPair.
      Overrides:
      toString in class Object