Example #1
0
  /**
   * Elimina la clave del almacen de claves
   *
   * @throws KeyStoreAccessException
   */
  public void reset() throws KeyStoreAccessException {
    try {
      keyBitmapCollection = new IcoFile(iconPath);
      keyBitmap = keyBitmapCollection.getBitmap(0);

      pixelPath.resetPath();

      removePresencePatternFromImage();

      keyBitmapCollection.saveToDisk(iconPath);
    } catch (IOException e) {
      throw new KeyStoreAccessException();
    } catch (IncorrectImageFormatException e) {
      throw new KeyStoreAccessException();
    }
  }
Example #2
0
  /**
   * Almacena la clave indicada en la imagen utilizada como almacén
   *
   * @param password Array de bytes que contiene la clave a guardar.
   * @throws KeyStoreAccessException Si se produce algun error al acceder al almacen de claves
   */
  public void saveKey(byte[] password) throws KeyStoreAccessException {
    try {
      keyBitmapCollection = new IcoFile(iconPath);
      keyBitmap = keyBitmapCollection.getBitmap(0);

      pixelPath.resetPath();

      encodePresencePatternInImage();

      byte keyLength = (byte) password.length;

      encodeByteInImage(keyLength);
      encodeByteArrayInImage(password);

      keyBitmapCollection.saveToDisk(iconPath);
    } catch (IOException e) {
      throw new KeyStoreAccessException();
    } catch (IncorrectImageFormatException e) {
      throw new KeyStoreAccessException();
    }
  }
Example #3
0
  /**
   * Carga la clave almacenada en la imagen que se utiliza como almacen
   *
   * @return Array de Bytes que contiene la clave recuperada
   * @throws KeyNotFoundException Si no se ha encontrado ninguna clave en la imagen
   * @throws KeyStoreAccessException Si se ha producido algun error al acceder al almacen de claves
   */
  public byte[] loadKey() throws KeyStoreAccessException, KeyNotFoundException {
    try {
      keyBitmapCollection = new IcoFile(iconPath);
      keyBitmap = keyBitmapCollection.getBitmap(0);

      pixelPath.resetPath();

      if (testPresencePattern() == false) throw new KeyNotFoundException();

      int keyLength = (decodeByteFromImage() & 0xFF);
      byte byteArrayKey[] = new byte[keyLength];

      for (int i = 0; i < byteArrayKey.length; i++) {
        byte currentByte = decodeByteFromImage();
        byteArrayKey[i] = currentByte;
      }

      return byteArrayKey;
    } catch (IOException e) {
      throw new KeyStoreAccessException();
    } catch (IncorrectImageFormatException e) {
      throw new KeyStoreAccessException();
    }
  }