KeyMatcher, net.sergeych.tools.Bindable, net.sergeych.tools.HashableRSAOAEPPublicKeypublic abstract class AbstractPublicKey extends AbstractAsymmetricKey implements net.sergeych.tools.Hashable
Important: The Key can be in not-initialized state after creation, in which case the depending
methods must throw IllegalStateException. Non-initialized state is a transient state
between creation and construction from the hash or generation new key.
Created by sergeych on 15/04/16.
MAX_SALT_LENGTHFINGERPRINT_SHA256, FINGERPRINT_SHA384, keyInfo, TYPE_PRIVATE, TYPE_PRIVATE_PASSWORD, TYPE_PRIVATE_PASSWORD_V2, TYPE_PUBLIC| Constructor | Description |
|---|---|
AbstractPublicKey() |
| Modifier and Type | Method | Description |
|---|---|---|
abstract java.lang.String |
algorithmTag() |
Any encryption type has an unique tag.
|
abstract boolean |
canEncrypt() |
Check that this key instance is suitable for encryption too (some keys can provide
checkSignature only functionality).
|
boolean |
checkSignature(byte[] input,
byte[] signature,
HashType hashType) |
|
boolean |
checkSignature(byte[] input,
byte[] signature,
HashType hashType,
int saltLength) |
|
boolean |
checkSignature(java.io.InputStream input,
byte[] signature,
HashType hashType) |
Check the digital signature.
|
abstract boolean |
checkSignature(java.io.InputStream input,
byte[] signature,
HashType hashType,
int saltLength) |
Check the digital signature.
|
boolean |
checkSignature(java.lang.String data,
byte[] signature,
HashType hashType) |
|
abstract byte[] |
encrypt(byte[] plaintext) |
Public-key encryption of the block.
|
byte[] |
encrypt(java.lang.String data) |
Encrypt data of the string using UTF-8 encoding
|
abstract int |
getBitStrength() |
|
abstract boolean |
isInitialized() |
True if the key is properly initialized
|
getMaxSaltLengthaddress, asKeySource, canSign, createAnonymousId, decrypt, fingerprint, fromBinder, getLongAddress, getPublicKey, getShortAddress, info, isMatchingKey, isMatchingKeyAddress, isPrivate, isPublic, matchAnonymousId, matchTag, matchType, pack, packedInfo, packToBase64String, setTag, setTag, sign, sign, toBinder, toString, unpack, updateDigestWithKeyComponents, updateFrom, verify, verify, verifypublic abstract boolean canEncrypt()
public abstract int getBitStrength()
public abstract boolean isInitialized()
public abstract byte[] encrypt(byte[] plaintext)
throws EncryptionError
encrypt in class AbstractKeyplaintext - data to encrypt.EncryptionError - if the key can't encrypt, data too large for the key or any other error that prevents
data to be encrypted.public abstract boolean checkSignature(java.io.InputStream input,
byte[] signature,
HashType hashType,
int saltLength)
throws java.io.IOException,
java.lang.IllegalStateException
The method must not throw exception if the signature is bad. e.g. improper, has wrong structure and so on. Instead, it must return false.
input - source datasignature - signature to checkjava.io.IOException - failed to read the input stream (including empty stream, EOF at start)java.lang.IllegalStateExceptionpublic boolean checkSignature(java.io.InputStream input,
byte[] signature,
HashType hashType)
throws java.io.IOException,
java.lang.IllegalStateException
The method must not throw exception if the signature is bad. e.g. improper, has wrong structure and so on. Instead, it must return false.
input - source datasignature - signature to checkjava.io.IOException - failed to read the input stream (including empty stream, EOF at start)java.lang.IllegalStateExceptionpublic abstract java.lang.String algorithmTag()
public boolean checkSignature(byte[] input,
byte[] signature,
HashType hashType,
int saltLength)
input - to check the signature against.signature - signature to checkhashType - type of the hash function used to create the signaturepublic boolean checkSignature(byte[] input,
byte[] signature,
HashType hashType)
input - to check the signature against.signature - signature to checkhashType - type of the hash function used to create the signaturepublic boolean checkSignature(java.lang.String data,
byte[] signature,
HashType hashType)
data - to check the signature against.signature - signature to checkpublic byte[] encrypt(java.lang.String data)
throws EncryptionError
data - to encryptEncryptionError