Signature
classin packageklyn.cryptography
public abstract class Signature extends Object:
Abstract base class for digital signatures.
The concrete RSA APIs are exposed through `RSAPSSSignature` and
`RSAPKCS1Signature`, parameterized by a concrete digest such as `SHA256()`
or `SHA512()`.
import klyn.cryptography
keys = RSAKeyPairGenerator().generateKeyPair()
signer as Signature = RSAPSSSignature(SHA256())
signer.initSign(keys.privateKeyPem)
token = signer.sign("hello")
verifier as Signature = RSAPSSSignature(SHA256())
verifier.initVerify(keys.publicKeyPem)
print(verifier.verify(token, "hello"))
Fields
| Modifier and Type |
Member |
Description |
| public readonly |
algorithm |
Canonical signature algorithm name. |
| public readonly |
hashAlgorithm |
Canonical digest algorithm name used by the signature. |
| public readonly |
padding |
RSA padding mode used by the signature. |
Methods
| Modifier and Type |
Member |
Description |
| public static |
getInstance |
Compatibility factory for dynamic algorithm selection. |
| public |
initSigninitSign(privateKeyPem as String) as Void: |
Initializes the instance for signing with a private key. |
| public |
initVerifyinitVerify(publicKeyPem as String) as Void: |
Initializes the instance for verification with a public key. |
| public |
reset reset() as Void:
|
Clears the buffered text accumulated with `update`. |
| public |
sign |
Signs the buffered text and an optional final chunk. |
| public override |
toString |
No summary. |
| public |
update |
Appends text to the in-memory signature buffer. |
| public |
verify |
Verifies a signature against the buffered text and an optional final chunk. |