public static SecretKeys keys(String keysStr) throws InvalidKeyException {
  String[] keysArr=keysStr.split(":");
  if (keysArr.length != 2) {
    throw new IllegalArgumentException("Cannot parse aesKey:hmacKey");
  }
 else {
    byte[] confidentialityKey=Base64.decode(keysArr[0],BASE64_FLAGS);
    if (confidentialityKey.length != AES_KEY_LENGTH_BITS / 8) {
      throw new InvalidKeyException("Base64 decoded key is not " + AES_KEY_LENGTH_BITS + " bytes");
    }
    byte[] integrityKey=Base64.decode(keysArr[1],BASE64_FLAGS);
    if (integrityKey.length != HMAC_KEY_LENGTH_BITS / 8) {
      throw new InvalidKeyException("Base64 decoded key is not " + HMAC_KEY_LENGTH_BITS + " bytes");
    }
    return new SecretKeys(new SecretKeySpec(confidentialityKey,0,confidentialityKey.length,CIPHER),new SecretKeySpec(integrityKey,HMAC_ALGORITHM));
  }
}

public static SecretKeys keys ( String keysStr ) throws InvalidKeyException { String [ ] keysArr = keysStr . split ( ":" ) ; if ( keysArr . length != 2 ) { throw new IllegalArgumentException ( "Cannot parse aesKey:hmacKey" ) ; } else { byte [ ] confidentialityKey = Base64 . decode ( keysArr [ 0 ] , BASE64_FLAGS ) ; if ( confidentialityKey . length != AES_KEY_LENGTH_BITS / 8 ) { throw new InvalidKeyException ( "Base64 decoded key is not " + AES_KEY_LENGTH_BITS + " bytes" ) ; } byte [ ] integrityKey = Base64 . decode ( keysArr [ 1 ] , BASE64_FLAGS ) ; if ( integrityKey . length != HMAC_KEY_LENGTH_BITS / 8 ) { throw new InvalidKeyException ( "Base64 decoded key is not " + HMAC_KEY_LENGTH_BITS + " bytes" ) ; } return new SecretKeys ( new SecretKeySpec ( confidentialityKey , 0 , confidentialityKey . length , CIPHER ) , new SecretKeySpec ( integrityKey , HMAC_ALGORITHM ) ) ; } }
an aes key derived from a base64 encoded key . this does not generate the key . it ' s not random or a pbe key .
