Class HsmEnclaveClient

  • All Implemented Interfaces:
    NativeHandleGuard.Owner

    public class HsmEnclaveClient
    extends java.lang.Object
    implements NativeHandleGuard.Owner
    HsmEnclaveClient provides bindings to interact with Signal's HSM-backed enclave. Interaction with the enclave is done over a websocket, which is handled by the client. Once the websocket has been initiated, the client establishes a connection in the following manner:
    • send HsmEnclaveClient.initialRequest()
    • receive a response and pass to HsmEnclaveClient.completeHandshake()
    After a connection has been established, a client may send or receive messages. To send a message, they formulate the plaintext, then pass it to HsmEnclaveClient.establishedSend() to get the ciphertext message to pass along. When a message is received (as ciphertext), it is passed to HsmEnclaveClient.establishedRecv(), which decrypts and verifies it, passing the plaintext back to the client for processing.
    • Constructor Summary

      Constructors 
      Constructor Description
      HsmEnclaveClient​(byte[] public_key, java.util.List<byte[]> code_hashes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void completeHandshake​(byte[] handshakeResponse)
      Called by client upon receipt of first message from HSM enclave, to complete handshake.
      byte[] establishedRecv​(byte[] receivedCiphertext)
      Called by client after completeHandshake has succeeded, to decrypt a received message.
      byte[] establishedSend​(byte[] plaintextToSend)
      Called by client after completeHandshake has succeeded, to encrypt a message to send.
      protected void finalize()  
      byte[] initialRequest()
      Initial request to send to HSM enclave, to begin handshake.
      long unsafeNativeHandleWithoutGuard()  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HsmEnclaveClient

        public HsmEnclaveClient​(byte[] public_key,
                                java.util.List<byte[]> code_hashes)
    • Method Detail

      • finalize

        protected void finalize()
        Overrides:
        finalize in class java.lang.Object
      • initialRequest

        public byte[] initialRequest()
        Initial request to send to HSM enclave, to begin handshake.
      • completeHandshake

        public void completeHandshake​(byte[] handshakeResponse)
        Called by client upon receipt of first message from HSM enclave, to complete handshake.
      • establishedSend

        public byte[] establishedSend​(byte[] plaintextToSend)
        Called by client after completeHandshake has succeeded, to encrypt a message to send.
      • establishedRecv

        public byte[] establishedRecv​(byte[] receivedCiphertext)
        Called by client after completeHandshake has succeeded, to decrypt a received message.