/** * Returns the byte length of the specified byte array. * * @param byteArray The byte array. May be {@code null}. * * @return The bite length, zero if the array is {@code null}. */ public static int bitLength(final byte[] byteArray) { if (byteArray == null) { return 0; } else { return bitLength(byteArray.length); } }
/** * Creates a new Message Authentication (MAC) signer. * * @param secret The secret. Must be at least 256 bits long and not * {@code null}. * * @throws KeyLengthException If the secret length is shorter than the * minimum 256-bit requirement. */ public MACSigner(final byte[] secret) throws KeyLengthException { super(secret, getCompatibleAlgorithms(ByteUtils.bitLength(secret.length))); }
@Override public int size() { return ByteUtils.bitLength(x.decode()); }
/** * Creates a new AES encryption / decryption provider. * * @param kek The Key Encryption Key. Must be 128 bits (16 bytes), 192 * bits (24 bytes) or 256 bits (32 bytes). Must not be * {@code null}. * * @throws KeyLengthException If the KEK length is invalid. */ protected AESCryptoProvider(final SecretKey kek) throws KeyLengthException { super(getCompatibleJWEAlgorithms(ByteUtils.bitLength(kek.getEncoded())), ContentCryptoProvider.SUPPORTED_ENCRYPTION_METHODS); this.kek = kek; }
/** * Creates a new direct encryption / decryption provider. * * @param cek The Content Encryption Key (CEK). Must be 128 bits (16 * bytes), 192 bits (24 bytes), 256 bits (32 bytes), 384 * bits (48 bytes) or 512 bits (64 bytes) long. Must not be * {@code null}. * * @throws KeyLengthException If the CEK length is not compatible. */ protected DirectCryptoProvider(final SecretKey cek) throws KeyLengthException { super(SUPPORTED_ALGORITHMS, getCompatibleEncryptionMethods(ByteUtils.bitLength(cek.getEncoded()))); this.cek = cek; }