sig.update(data);
byte[] signature = sig.sign();
byte[] decoded = new byte[40];
SimpleASNReader asn = new SimpleASNReader(signature);
asn.getByte();
asn.getLength();
asn.getByte();
byte[] r = asn.getData();
asn.getByte();
byte[] s = asn.getData();
if (r.length >= 20) {
System.arraycopy(r, r.length - 20, decoded, 0, 20);
} else {
System.arraycopy(r, 0, decoded, 20 - r.length, r.length);