|
29 | 29 | import org.bouncycastle.bcpg.UserIDPacket; |
30 | 30 | import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator; |
31 | 31 | import org.bouncycastle.util.Arrays; |
| 32 | +import org.bouncycastle.util.Pack; |
32 | 33 |
|
33 | 34 | /** |
34 | 35 | * general class to handle a PGP public key object. |
@@ -67,25 +68,11 @@ private void init(KeyFingerPrintCalculator fingerPrintCalculator) |
67 | 68 | } |
68 | 69 | else if (publicPk.getVersion() == PublicKeyPacket.VERSION_4) |
69 | 70 | { |
70 | | - this.keyID = ((long)(fingerprint[fingerprint.length - 8] & 0xff) << 56) |
71 | | - | ((long)(fingerprint[fingerprint.length - 7] & 0xff) << 48) |
72 | | - | ((long)(fingerprint[fingerprint.length - 6] & 0xff) << 40) |
73 | | - | ((long)(fingerprint[fingerprint.length - 5] & 0xff) << 32) |
74 | | - | ((long)(fingerprint[fingerprint.length - 4] & 0xff) << 24) |
75 | | - | ((long)(fingerprint[fingerprint.length - 3] & 0xff) << 16) |
76 | | - | ((long)(fingerprint[fingerprint.length - 2] & 0xff) << 8) |
77 | | - | ((fingerprint[fingerprint.length - 1] & 0xff)); |
| 71 | + this.keyID = Pack.bigEndianToLong(fingerprint, fingerprint.length - 8); |
78 | 72 | } |
79 | 73 | else if (publicPk.getVersion() == PublicKeyPacket.VERSION_6) |
80 | 74 | { |
81 | | - this.keyID = ((long)(fingerprint[0] & 0xff) << 56) |
82 | | - | ((long)(fingerprint[1] & 0xff) << 48) |
83 | | - | ((long)(fingerprint[2] & 0xff) << 40) |
84 | | - | ((long)(fingerprint[3] & 0xff) << 32) |
85 | | - | ((long)(fingerprint[4] & 0xff) << 24) |
86 | | - | ((long)(fingerprint[5] & 0xff) << 16) |
87 | | - | ((long)(fingerprint[6] & 0xff) << 8) |
88 | | - | ((long)(fingerprint[7] & 0xff)); |
| 75 | + this.keyID = Pack.bigEndianToLong(fingerprint, 0); |
89 | 76 | } |
90 | 77 |
|
91 | 78 | // key strength |
|
0 commit comments