Download this file

AuthenticatedEncryption.java    90 lines (78 with data), 3.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package cologne.eck.peafactory.crypto;
import cologne.eck.all_peas.files.FileComposer;
/*
* Peafactory - Production of Password Encryption Archives
* Copyright (C) 2015 Axel von dem Bruch
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* See: http://www.gnu.org/licenses/gpl-2.0.html
* You should have received a copy of the GNU General Public License
* along with this library.
*/
//import org.bouncycastle.crypto.InvalidCipherTextException;
/**
* Interface for mode of operation of authenticated encryption/decryption
*/
public interface AuthenticatedEncryption {
/**
* Encrypt/decrypt an array of bytes
*
* @param forEncryption - true for encryption, false for decryption
* @param input - plain text or cipher text
* @param key - the cryptographic key for the cipher
* @param nonce - unique nonce of 16 byte
* @return - plain text or cipher text
*/
public byte[] processBytes(
boolean forEncryption,
byte[] input,
byte[] key,
byte[] nonce);
/**
* Encrypt/decrypt an array of bytes but without MAC (MAC size 0)
* - this is used to check the password identifier for each file before
* the decryption of the file starts.
*
* @param forEncryption - true for encryption, false for decryption
* @param input - plain text or cipher text
* @param key - the cryptographic key for the cipher
* @param nonce - unique Nonce of 16 byte
* @return - plain text or cipher text
*/
public byte[] processBytesNoMAC(
boolean forEncryption,
byte[] input,
byte[] key,
byte[] nonce);
/**
* Decrypt an array of files
*
* @param fileNames array of file names
* @param keyMaterial derived material from KDF, contains the key
* @param encryptKeyBySessionKey whether encrypt and store the derived key
* or zeroize it
* @param fileComposer FileComposer, used to display the progressPro100 of encryption
* @return array of error messages, with the same indexing as fileNames
*/
public String[] decryptFiles( String[] fileNames, byte[] keyMaterial,
boolean encryptBySessionKey, FileComposer fileComposer);
/**
* Encrypt an array of files
*
* @param fileNames array of file names
* @param keyMaterial derived material from KDF, contains the key
* @param encryptBySessionKey whether encrypt and store the derived key
* or zeroize it
* @param fileComposer FileComposer, used to display the progressPro100 of encryption
* @return array of error messages, with the same indexing as fileNames
*/
public String[] encryptFiles( String[] fileNames, byte[] keyMaterial,
boolean encryptBySessionKey, FileComposer fileComposer);
}