-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCryptoSystem.java
35 lines (28 loc) · 1.26 KB
/
CryptoSystem.java
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
//package ecc;
import java.io.*;
/** This interface is used to model a modern cryptosystem. It contains methods
to encrypt and decrypt and methods to generate keys for the specific cryptosystem.
In an actual implementation it would be a good idea to initialize a key inside
the constructor method.*/
public interface CryptoSystem{
/** Encrypts the string p.
*@param plain the plaintext to be encrypted.
*@param ek The (public) key to use for encryption.
*@return the input string encrypted with the current key.
*/
public byte[] encrypt(byte[] plain, int numbytes, Key ek);
/** Decrypts the string c.
*@param cipher the ciphertext to be decrypted.
*@param sk the (secret) key to use for decryption.
*@return the input string decrypted with the current key.
*/
public byte[] decrypt(byte[] cipher, Key dk);
/** This method generates a new key for the cryptosystem.
*@return the new key generated*/
public Key generateKey();
/** This method returns the maximum size of blocks it can encrypt.
*@return the maximum block size the system can encrypt. */
public int blockSize();
/** Returns a String describing this CryptoSystem*/
public String toString();
}