Class Crypto

java.lang.Object
io.ably.lib.util.Crypto

public class Crypto
extends java.lang.Object
Contains the properties required to configure the encryption of Message payloads.
  • Field Details

  • Constructor Details

  • Method Details

    • getDefaultParams

      public static Crypto.CipherParams getDefaultParams()

      Spec: RSE1

      Returns:
      A Crypto.CipherParams object, using the default values for all fields.
    • getDefaultParams

      public static Crypto.CipherParams getDefaultParams​(byte[] key)

      Spec: RSE1

      Parameters:
      key - client-provided key
      Returns:
      A Crypto.CipherParams object, using the default values for any fields not supplied.
    • getDefaultParams

      public static Crypto.CipherParams getDefaultParams​(java.lang.String base64Key)

      Spec: RSE1

      Parameters:
      base64Key - Base64-encoded key
      Returns:
      A Crypto.CipherParams object, using the default values for any fields not supplied.
    • getParams

      public static Crypto.CipherParams getParams​(java.lang.String algorithm, int keyLength)
    • getParams

      public static Crypto.CipherParams getParams​(java.lang.String algorithm, byte[] key) throws java.security.NoSuchAlgorithmException
      Throws:
      java.security.NoSuchAlgorithmException
    • getParams

      public static Crypto.CipherParams getParams​(java.lang.String algorithm, byte[] key, byte[] iv) throws java.security.NoSuchAlgorithmException
      Throws:
      java.security.NoSuchAlgorithmException
    • generateRandomKey

      public static byte[] generateRandomKey​(int keyLength)
      Generates a random key to be used in the encryption of the channel. If the language cryptographic randomness primitives are blocking or async, a callback is used. The callback returns a generated binary key.

      Spec: RSE2

      Parameters:
      keyLength - The length of the key, in bits, to be generated. If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.
      Returns:
      The key as a binary, in a byte array.
    • generateRandomKey

      public static byte[] generateRandomKey()
      Generates a random key to be used in the encryption of the channel. If the language cryptographic randomness primitives are blocking or async, a callback is used. The callback returns a generated binary key.

      Spec: RSE2

      Returns:
      The key as a binary, in a byte array.
    • createChannelCipherSet

      public static Crypto.ChannelCipherSet createChannelCipherSet​(java.lang.Object cipherParams) throws AblyException
      Internal; get an encrypting cipher instance based on the given channel options.
      Throws:
      AblyException
    • getRandomId

      public static java.lang.String getRandomId()
    • generateRandomRequestId

      public static Param generateRandomRequestId()
      Returns a "request_id" query param, based on a sequence of 9 random bytes which have been base64 encoded. Spec: RSC7c