Esempio n. 1
0
 /**
  * Key Derivation Function for client.dat: Use the database key as an HMAC key to an HMAC of the
  * key plus some constant plus the storeIdentifier.
  *
  * @return An encryption key, as byte[].
  */
 public byte[] getKeyForClientLayer() {
   byte[] full = new byte[databaseKey.length + CLIENT_LAYER.length];
   int x = 0;
   System.arraycopy(databaseKey, 0, full, 0, databaseKey.length);
   x += databaseKey.length;
   System.arraycopy(CLIENT_LAYER, 0, full, x, CLIENT_LAYER.length);
   return HMAC.macWithSHA256(databaseKey, full);
 }
Esempio n. 2
0
 /**
  * Key Derivation Function for plugin stores: Use the database key as an HMAC key to an HMAC of
  * the key plus some constant plus the storeIdentifier.
  *
  * @param storeIdentifier The classname of the plugin, used as part of a filename.
  * @return An encryption key, as byte[].
  */
 public byte[] getPluginStoreKey(String storeIdentifier) {
   try {
     byte[] id = storeIdentifier.getBytes("UTF-8");
     byte[] full = new byte[databaseKey.length + PLUGIN.length + id.length];
     int x = 0;
     System.arraycopy(databaseKey, 0, full, 0, databaseKey.length);
     x += databaseKey.length;
     System.arraycopy(PLUGIN, 0, full, x, PLUGIN.length);
     x += PLUGIN.length;
     System.arraycopy(id, 0, full, x, id.length);
     return HMAC.macWithSHA256(databaseKey, full);
   } catch (UnsupportedEncodingException e) {
     throw new Error(e);
   }
 }