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");
    }
    SecretKeys secretKeys=new SecretKeys();
    SecretKeySpec secretKeySpec=new SecretKeySpec();
    secretKeySpec.generate(confidentialityKey,0,confidentialityKey.length,CIPHER);
    SecretKeySpec secretKeySpec1=new SecretKeySpec();
    secretKeySpec1.generate(integrityKey,HMAC_ALGORITHM);
    secretKeys.setConfidentialityKey(secretKeySpec);
    secretKeys.setIntegrityKey(secretKeySpec1);
    return secretKeys;
  }
}

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" ) ; } SecretKeys secretKeys = new SecretKeys ( ) ; SecretKeySpec secretKeySpec = new SecretKeySpec ( ) ; secretKeySpec . generate ( confidentialityKey , 0 , confidentialityKey . length , CIPHER ) ; SecretKeySpec secretKeySpec1 = new SecretKeySpec ( ) ; secretKeySpec1 . generate ( integrityKey , HMAC_ALGORITHM ) ; secretKeys . setConfidentialityKey ( secretKeySpec ) ; secretKeys . setIntegrityKey ( secretKeySpec1 ) ; return secretKeys ; } }
an aes key derived from a base64 encoded key . this does not generate the key . it ' s not random or a pbe key .
