kz.greetgo.security.crypto.Crypto Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greetgo.security Show documentation
Show all versions of greetgo.security Show documentation
Security infrastructure used in greetgo!
package kz.greetgo.security.crypto;
import java.security.SecureRandom;
/**
*
* Encrypt and decrypt data. Sign and verify signature of data. Random generation.
*
*
* Key pair will generate automatically and saved into key storage on first using
*
*
* To create implementation use {@link CryptoBuilder}
*
*/
public interface Crypto {
/**
* Encrypt data using public key
*
* @param bytes data to encrypt
* @return entrypted data
*/
byte[] encrypt(byte[] bytes);
/**
* Decrypt encrypted data using private key
*
* @param encryptedBytes encrypted data
* @return decrypted (original) data
*/
byte[] decrypt(byte[] encryptedBytes);
/**
* Sign data
*
* @param bytes the data to sign
* @return signature
*/
byte[] sign(byte[] bytes);
/**
* Verifies signature
*
* @param bytes checking data
* @param signature verifying signature
* @return verification result: true
- verification is OK, otherwise - verification wrong
*/
boolean verifySignature(byte[] bytes, byte[] signature);
/**
* Gives security random generator
*
* @return security random generator
*/
SecureRandom rnd();
}