5Q0907530F
Открытый ключ для функции SWaP
SWaP_public_key
99 19 70 20 DD A9 1D 14 0A BB A4 90 B5 ED 09 97 32 66 86 77 B6 FC 36 C9 0F 44 99 7F 58 BF 1C 99 82 8C DD 35 B4 F5 BB 76 4F 28 2E 4A 4B AA 98 44 D5 65 19 9D 70 BD 6E 67 C7 B2 D6 C9 37 77 57 DD CE 12 D4 A1 15 32 59 88 5E 5C 05 4B C4 B9 D5 8F 18 83 0E BA 93 C1 43 56 0F A4 B6 B9 3C 79 66 8F D7 5B 33 70 34 84 1E 8E D7 AE CD B8 E6 0E 29 FC D5 60 B3 F6 EC FD E2 D3 2B 1A 7D 78 41 88 78 F9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03
swap fsc
11 02 10 00 03 00
03 48 34 05 9E 80
57 56 57 5A 5A 5A
41 55 5A 45 50 30
32 32 34 37 38 00
55 4B 18 63 00 00
00 00 00 00 00 00
00 45 41 D3 C4 D2
4A 9B A1 57 31 4B
E9 97 01 EA 86 2D
66 49 D0 09 1D 05
05 BD C3 7B 3A 80
1D F9 02 C7 3D 08
C8 EB A3 36 B2 48
D8 DE 7D 09 B2 64
DC CF A0 68 D1 3B
E5 67 46 06 84 0D
73 FE E1 FC 31 E9
13 2A 67 7D E8 C4
3D A0 9E 93 48 B6
FD 5F 95 B2 38 11
32 83 6E F2 E7 66
54 AA 2D 57 5A FC
96 02 CB 2F AD F9
98 8F 04 4D 66 85
AA 2A DC 09 8F 48
05 37 02 95 E0 4F
68 6B A5 01 E7 6A
3A E6 3D
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.Security;
import java.security.Signature;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.RSAPublicKeySpec;
import org.bouncycastle.jce.provider.BouncyCastleProvider ;
public class SignatureCheck {
public static void main(String[] args) throws Exception {
Security.addProvider(new BouncyCastleProvider());
String messageHex = "11 02 10 00 03 00 03 48 34 05 9E 80 57 56 57 5A 5A 5A 41 55 5A 45 50 30 32 32 34 37 38 00 55 4B 18 63 00 00 00 00 00 00 00 00 00";
byte[] messageBytes = getBytesFromHexString(messageHex);
String modulusHexSpaced = "99 19 70 20 DD A9 1D 14 0A BB A4 90 B5 ED 09 97 32 66 86 77 B6 FC 36 C9 0F 44 99 7F 58 BF 1C 99 82 8C DD 35 B4 F5 BB 76 4F 28 2E 4A 4B AA 98 44 D5 65 19 9D 70 BD 6E 67 C7 B2 D6 C9 37 77 57 DD CE 12 D4 A1 15 32 59 88 5E 5C 05 4B C4 B9 D5 8F 18 83 0E BA 93 C1 43 56 0F A4 B6 B9 3C 79 66 8F D7 5B 33 70 34 84 1E 8E D7 AE CD B8 E6 0E 29 FC D5 60 B3 F6 EC FD E2 D3 2B 1A 7D 78 41 88 78 F9";
String[] modulusHexSplit = modulusHexSpaced.split(" ");
String modulusHex = "";
int i = 0;
for (String s : modulusHexSplit) {
modulusHex += s;
i++;
}
BigInteger modulus = new BigInteger(modulusHex, 16);
String exponentHex = "03";
BigInteger exponent = new BigInteger(exponentHex, 16);
RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, exponent);
KeyFactory keyFac = KeyFactory.getInstance("RSA");
RSAPublicKey rsaPub = (RSAPublicKey) keyFac.generatePublic(pubKeySpec);
String sigBytesHex = "45 41 D3 C4 D2 4A 9B A1 57 31 4B E9 97 01 EA 86 2D 66 49 D0 09 1D 05 05 BD C3 7B 3A 80 1D F9 02 C7 3D 08 C8 EB A3 36 B2 48 D8 DE 7D 09 B2 64 DC CF A0 68 D1 3B E5 67 46 06 84 0D 73 FE E1 FC 31 E9 13 2A 67 7D E8 C4 3D A0 9E 93 48 B6 FD 5F 95 B2 38 11 32 83 6E F2 E7 66 54 AA 2D 57 5A FC 96 02 CB 2F AD F9 98 8F 04 4D 66 85 AA 2A DC 09 8F 48 05 37 02 95 E0 4F 68 6B A5 01 E7 6A 3A E6 3D";
byte[] signBytes = getBytesFromHexString(sigBytesHex);
Signature sign = Signature.getInstance("RipeMd160withRSA");
sign.initVerify(rsaPub);
sign.update(messageBytes);
if (sign.verify(signBytes)) {
System.out.println("Signature true");
} else {
System.out.println("Signature false");
}
}
private static byte[] getBytesFromHexString(String hexString) {
byte[] buff = new byte[128];
String[] splitted = hexString.split(" ");
int i = 0;
for (String s : splitted) {
buff[i] = (byte) Integer.parseInt(s, 16);
i++;
}
byte[] result = new byte[i];
for (int index = 0; index < i; index++) {
result[index] = buff[index];
}
return result;
}
}
Signature true
Последний раз редактировалось Neo_; 01.06.2020 в 00:43..
|