SignVerifyHash.java

Exemplo de assinatura e verificação.

Veja Nota sobre os exemplos.
package doxy.examples;
public class SignVerifyHash {
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
api.openSession("10.0.62.47", "master", "12345678", false);
byte[] message = { (byte)0xD5, (byte)0x17, (byte)0xED, (byte)0x40, (byte)0x1D,
(byte)0xF3, (byte)0x03, (byte)0x38, (byte)0x37, (byte)0xE0,
(byte)0x8B, (byte)0x62, (byte)0x55, (byte)0xBE, (byte)0xDB,
(byte)0xF9, (byte)0x52, (byte)0x0E, (byte)0xF8, (byte)0x8E };
String keyId = "rsa";
api.deleteKey(keyId);
api.createKey(keyId, TacNDJavaLib.ALG_RSA_2048);
byte[] signature = api.signHash(keyId, TacNDJavaLib.ALG_SHA2_256, message);
api.verifySignature(keyId, TacNDJavaLib.ALG_SHA2_256, signature, message);
api.closeSession();
}
}