Exemplo n.º 1
0
  @Override
  public boolean addUsername(
      String username, byte[] encodedUserKey, byte[] signed, byte[] staticData) {
    UserPublicKey key = new UserPublicKey(encodedUserKey);

    if (!key.isValidSignature(
        signed, ArrayOps.concat(username.getBytes(), encodedUserKey, staticData))) return false;

    UserPublicKey existingKey = getPublicKey(username);
    if (existingKey != null) return false;
    String existingUsername = getUsername(key.getPublicKeys());
    if (existingUsername.length() > 0) return false;

    UserData user = new UserData(username, key.getPublicKeys());
    return user.insert();
  }
Exemplo n.º 2
0
 public byte[] decrypt(SymmetricKey key, byte[] iv) {
   return key.decrypt(ArrayOps.concat(auth, encrypted), iv);
 }