fm.liveswitch.RsaCrypto Class Reference

RSA-based cryptographic functions. More...

Static Public Member Functions

static int getDefaultKeySize ()
 
static void setDefaultKeySize (int defaultKeySize)
 
static RsaKey createKey ()
 Creates an RSA key. More...
 
static RsaKey createKey (int keySize)
 Creates an RSA key. More...
 
static PrivateKey getPrivateKey (RsaKey key) throws Exception
 
static PublicKey getPublicKey (RsaKey key) throws Exception
 
static byte[] signMd5Sha1 (byte[] md5sha1, RsaKey privateKey)
 Signs an MD5/SHA-1 hash using a specified key. More...
 
static boolean verifyMd5Sha1 (byte[] md5sha1, byte[] signature, RsaKey publicKey)
 Verifies an MD5/SHA-1 hash using a specified key and signature. More...
 
static byte[] signSha1 (byte[] sha1, RsaKey privateKey)
 Signs a SHA-1 hash using a specified key. More...
 
static boolean verifySha1 (byte[] sha1, byte[] signature, RsaKey publicKey)
 Verifies a signature using a specified key and SHA-1 hash. More...
 
static byte[] signSha256 (byte[] sha256, RsaKey privateKey)
 Signs a SHA-256 hash using a specified key. More...
 
static boolean verifySha256 (byte[] sha256, byte[] signature, RsaKey publicKey)
 Verifies a signature using a specified key and SHA-256 hash. More...
 
static byte[] encrypt (byte[] b, RsaKey publicKey)
 Encrypts a value using a specified public key. More...
 
static byte[] decrypt (byte[] b, RsaKey privateKey)
 Decrypts a value using a specified private key. More...
 

Detailed Description

RSA-based cryptographic functions.

Member Function Documentation

◆ createKey() [1/2]

static RsaKey fm.liveswitch.RsaCrypto.createKey ( )
static

Creates an RSA key.

Returns
An RSA key.

◆ createKey() [2/2]

static RsaKey fm.liveswitch.RsaCrypto.createKey ( int  keySize)
static

Creates an RSA key.

Returns
An RSA key.

◆ decrypt()

static byte [] fm.liveswitch.RsaCrypto.decrypt ( byte[]  b,
RsaKey  privateKey 
)
static

Decrypts a value using a specified private key.

Parameters
bThe input byte array.
privateKeyThe private key.
Returns
The output byte array.

◆ encrypt()

static byte [] fm.liveswitch.RsaCrypto.encrypt ( byte[]  b,
RsaKey  publicKey 
)
static

Encrypts a value using a specified public key.

Parameters
bThe input byte array.
publicKeyThe public key.
Returns
The output byte array.

◆ getDefaultKeySize()

static int fm.liveswitch.RsaCrypto.getDefaultKeySize ( )
static

◆ getPrivateKey()

static PrivateKey fm.liveswitch.RsaCrypto.getPrivateKey ( RsaKey  key) throws Exception
static

◆ getPublicKey()

static PublicKey fm.liveswitch.RsaCrypto.getPublicKey ( RsaKey  key) throws Exception
static

◆ setDefaultKeySize()

static void fm.liveswitch.RsaCrypto.setDefaultKeySize ( int  defaultKeySize)
static

◆ signMd5Sha1()

static byte [] fm.liveswitch.RsaCrypto.signMd5Sha1 ( byte[]  md5sha1,
RsaKey  privateKey 
)
static

Signs an MD5/SHA-1 hash using a specified key.

Parameters
md5sha1The MD5/SHA-1 hash.
privateKeyThe private key.
Returns
The output byte array.

◆ signSha1()

static byte [] fm.liveswitch.RsaCrypto.signSha1 ( byte[]  sha1,
RsaKey  privateKey 
)
static

Signs a SHA-1 hash using a specified key.

Parameters
sha1The SHA-1 hash.
privateKeyThe private key.
Returns
The output byte array.

◆ signSha256()

static byte [] fm.liveswitch.RsaCrypto.signSha256 ( byte[]  sha256,
RsaKey  privateKey 
)
static

Signs a SHA-256 hash using a specified key.

Parameters
sha256The SHA-256 hash.
privateKeyThe private key.
Returns
The output byte array.

◆ verifyMd5Sha1()

static boolean fm.liveswitch.RsaCrypto.verifyMd5Sha1 ( byte[]  md5sha1,
byte[]  signature,
RsaKey  publicKey 
)
static

Verifies an MD5/SHA-1 hash using a specified key and signature.

Parameters
md5sha1The MD5/SHA-1 hash.
signatureThe input signature.
publicKeyThe public key.
Returns
true if the signature is valid; otherwise, false.

◆ verifySha1()

static boolean fm.liveswitch.RsaCrypto.verifySha1 ( byte[]  sha1,
byte[]  signature,
RsaKey  publicKey 
)
static

Verifies a signature using a specified key and SHA-1 hash.

Parameters
sha1The SHA-1 hash.
signatureThe input signature.
publicKeyThe public key.
Returns
true if the signature is valid; otherwise, false.

◆ verifySha256()

static boolean fm.liveswitch.RsaCrypto.verifySha256 ( byte[]  sha256,
byte[]  signature,
RsaKey  publicKey 
)
static

Verifies a signature using a specified key and SHA-256 hash.

Parameters
sha256The SHA-256 hash.
signatureThe input signature.
publicKeyThe public key.
Returns
true if the signature is valid; otherwise, false.