Advertisement
kire_xyz94

Heavy Debugging

Sep 3rd, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.35 KB | None | 0 0
  1. ECC key:
  2.  
  3. class KeyHolder {
  4. byte[] mPrivateKey; // getPrivateKey()
  5. byte[] mPublicKeyDiffieHellman; // getPublicKeyDiffieHellman()
  6. byte[] mPublicKeySignature; // getPublicKeySignature()
  7. }
  8.  
  9. Secure mail: kire.win8@scrypt.biz
  10. Activation Code: 3ed39d
  11. App Unlock Password: kire123
  12. keyPassphrase = 9xr9clUvdT7M0sKVA7eqkIuv
  13. keyUserId = kire.win8 <kire.win8@scrypt.biz>
  14.  
  15. class AccountSetupCreatePGPFragment:
  16. performs async task:
  17. generateKeyRing();
  18. pgpKo.genEccKeyRing(userId, passphrase);
  19. pgpKo is class PGPKeyOpsEx
  20. userId = kire.win8 <kire.win8@scrypt.biz>
  21. passphrase = 9xr9clUvdT7M0sKVA7eqkIuv // char[24]
  22.  
  23.  
  24.  
  25. KeyHolder keyHolder = generateKeyHolder();
  26. keyHolder.mPrivateKey = { -107, 16, 42, -38, 121, 27, 99, 124, -56, 41, 29, -15, -120, -77, -63, 119, 24, -120, 115, 60, -70, 109, -63, 78, 101, -56, 79, 105, 44, 127, 11, 51 } // before clamp
  27. keyHolder.mPrivateKey = { -112, 16, 42, -38, 121, 27, 99, 124, -56, 41, 29, -15, -120, -77, -63, 119, 24, -120, 115, 60, -70, 109, -63, 78, 101, -56, 79, 105, 44, 127, 11, 115 } // after clamp
  28. keyHolder.mPublicKeyDiffieHellman = { -92, 81, -39, 97, 9, -106, 8, 95, -119, -95, -109, -76, 124, -14, -51, 68, -48, 75, -71, -85, -16, 50, 20, 59, -122, -119, 76, -63, 68, -83, 95, 101 } // generated by Curve25519.keygen()
  29. keyHolder.mPublicKeySignature = { -83, 37, -52, -34, -53, 66, 98, 64, -51, 122, -4, 1, -10, 97, -26, -77, -107, -52, -44, -49, -19, 123, 105, 31, -62, 7, -70, 61, -121, -24, -123, -21 } // generated by KeyHolderFast.computePublicSignatureKey(privateKey)
  30.  
  31.  
  32.  
  33. PGPKeyPair keyDH = generateEccKeyPair( PublicKeyAlgorithmTags.EXPERIMENTAL_1 = 100, new Curve25519PublicBCPGKey(keyHolder.getPublicKeyDiffieHellman()), keyHolder.getPrivateKey());
  34. algorithm publicKeyData secretKeyData
  35. class Curve25519PublicBCPGKey contains "private final byte[] key" which is a copy of keyHolder.mPublicKeyDiffieHellman
  36.  
  37. PGPPublicKey publicKey = new PGPPublicKey( new PublicKeyPacket(algorithm, new Date(), publicKeyData), new BcKeyFingerprintCalculator());
  38. publicKey.publicPk
  39. .key = keyHolder.mPublicKeyDiffieHellman
  40. .algorithm = 100
  41. .time = 1441275010
  42. .validDays = 0
  43. .version = 4
  44. .fingerprint = { 100, 55, 111, -35, 65, 34, -55, -125, 41, 93, 76, -20, 70, -110, 46, 71, 72, 52, -13, -114 } // byte[20]
  45. .keyID = 5085177812943696782 // this.keyID = (long)(this.fingerprint[this.fingerprint.length - 8] & 255) << 56 | (long)(this.fingerprint[this.fingerprint.length - 7] & 255) << 48 | (long)(this.fingerprint[this.fingerprint.length - 6] & 255) << 40 | (long)(this.fingerprint[this.fingerprint.length - 5] & 255) << 32 | (long)(this.fingerprint[this.fingerprint.length - 4] & 255) << 24 | (long)(this.fingerprint[this.fingerprint.length - 3] & 255) << 16 | (long)(this.fingerprint[this.fingerprint.length - 2] & 255) << 8 | (long)(this.fingerprint[this.fingerprint.length - 1] & 255);
  46.  
  47. PGPPrivateKey privateKey = new PGPPrivateKey( publicKey.getKeyID(), publicKey.getPublicKeyPacket(), new ECSecretBCPGKey(new BigInteger(1, secretKeyData)));
  48. .keyID = 5085177812943696782 // same as above
  49. privateKey.publicKeyPacket = publicKey.publicPk // same as above
  50. privateKeyDataPacket.x.value = 65161615512395807035342817837557454990394607989690084773539878837707585031027 // generated from keyHolder.mPrivateKey
  51. keyDH.priv = privateKey
  52. keyDH.pub = publicKey
  53.  
  54.  
  55.  
  56. PGPKeyPair keyEdDSA = generateEccKeyPair( PublicKeyAlgorithmTags.EXPERIMENTAL_2, new EdDSAPublicBCPGKey(keyHolder.getPublicKeySignature()), keyHolder.getPrivateKey());
  57. algorithm publicKeyData secretKeyData
  58. class EdDSAPublicBCPGKey contains "private final byte[] pk" which is a copy of keyHolder.mPublicKeySignature;
  59. it also contains "private static final EdDSANamedCurveSpec curveSpec" = { name = ""ed25519-sha-512", hashAlgo = "SHA-512", and other values }
  60.  
  61. PGPPublicKey publicKey = new PGPPublicKey( new PublicKeyPacket(algorithm, new Date(), publicKeyData), new BcKeyFingerprintCalculator());
  62. publicKey.publicPk
  63. .key = keyHolder.mPublicKeySignature
  64. .algorithm = 101
  65. .time = 1441276658
  66. .validDays = 0
  67. .version = 4
  68. .fingerprint = { 69, 90, 61, -38, -12, -105, 54, 116, 27, 20, -81, 40, 57, -7, 77, 0, -124, 102, 27, 75 } // byte[20]
  69. .keyID = 4177454793979468619 // this.keyID = (long)(this.fingerprint[this.fingerprint.length - 8] & 255) << 56 | (long)(this.fingerprint[this.fingerprint.length - 7] & 255) << 48 | (long)(this.fingerprint[this.fingerprint.length - 6] & 255) << 40 | (long)(this.fingerprint[this.fingerprint.length - 5] & 255) << 32 | (long)(this.fingerprint[this.fingerprint.length - 4] & 255) << 24 | (long)(this.fingerprint[this.fingerprint.length - 3] & 255) << 16 | (long)(this.fingerprint[this.fingerprint.length - 2] & 255) << 8 | (long)(this.fingerprint[this.fingerprint.length - 1] & 255);
  70.  
  71. PGPPrivateKey privateKey = new PGPPrivateKey( publicKey.getKeyID(), publicKey.getPublicKeyPacket(), new ECSecretBCPGKey(new BigInteger(1, secretKeyData)));
  72. .keyID = 4177454793979468619 // same as above
  73. privateKey.publicKeyPacket = publicKey.publicPk // same as above
  74. privateKeyDataPacket.x.value = 65161615512395807035342817837557454990394607989690084773539878837707585031027 // generated from keyHolder.mPrivateKey (apparently same as keyDH's)
  75. keyEdDSA.priv = privateKey
  76. keyEdDSA.pub = publicKey
  77.  
  78.  
  79.  
  80. pgpSignatureSubpacketGenerator // Next is setting up a PGPSignatureSubpacketGenerator
  81. pgpSignatureSubpacketGenerator.setPreferredSymmetricAlgorithms(false, encAlgs);
  82. pgpSignatureSubpacketGenerator.setPreferredHashAlgorithms(false, hashAlgs);
  83. pgpSignatureSubpacketGenerator.setPreferredCompressionAlgorithms(false, comprAlgs);
  84. pgpSignatureSubpacketGenerator.setFeature(false, Features.FEATURE_MODIFICATION_DETECTION);
  85. pgpSignatureSubpacketGenerator.setKeyFlags(false, KeyFlags.CERTIFY_OTHER + KeyFlags.SIGN_DATA);
  86. PGPSignatureSubpacketVector hashedPcks = pgpSignatureSubpacketGenerator.generate();
  87.  
  88. // SHA1 is used for the checksum calculator; it's the only algorithm allowed.
  89. PGPKeyRingGenerator generator = new PGPKeyRingGenerator(
  90. PGPSignature.POSITIVE_CERTIFICATION, // 19
  91. keyEdDSA, // from above
  92. keyUserId, // ""kire.win8 <kire.win8@scrypt.biz>" - this is an unfortunately named string variable
  93. new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1),
  94. hashedPcks,
  95. null, // unhashedPcks,
  96. new EdDSAContentSigner.Builder(),
  97. new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256).build(keyPassphrase.toCharArray()));
  98. generator.addSubKey(keyDH);
  99.  
  100.  
  101.  
  102. this.pgpPublicKeyRingECC = generator.generatePublicKeyRing();
  103. // PGPPublicKeyRing - This class has a list of keys "private List keys"
  104. keys[0].fingerprint = keyDH.pub.fingerprint
  105. keys[0].publicPk = keyDH.pub.publicPk
  106. keys[0].keyID = keyDH.pub.keyID
  107. this.pgpSecretKeyRingECC = generator.generateSecretKeyRing();
  108. // PGPSecretKeyRing - This class has 2 member variables "private List keys" and "List extraPubKeys"
  109. extraPubKeys = new ArrayList(); // this is just an empty list
  110. keys[0].pub = keyEdDSA.pub
  111. keys[0].secret
  112. .secKeyData = { -74, 31, -45, -11, -62, 50, -27, 120, 115, -70, -104, 36, 119, -75, -25, 110, -89, -90, -84, -14, -42, 36, 101, 0, 121, -112, 117, -11, 97, -124, 2, -110, -7, -99, -23, 63, 79, -84, 72, 31, -53, -88, 58, -13, 109, -89, 62, 1, 46, 74, -128, -77, -4, -30 } // byte[54]
  113. .iv = { -85, 19, 71, -32, 52, -106, 48, -121, 64, 32, -67, 111, -68, 75, -34, 14 } // byte[16]
  114. .pubKeyPacket = keyEdDSA.pub
  115. .s2k.iv = { 18, 9, -128, 119, -66, -32, -43, -40 } // byte[8]
  116. .itCount = 96
  117. .algorithm = 2
  118. .protectionMode = -1
  119. .type = 3
  120. .s2kUsage = 254
  121. .encAlgorithm = 9
  122. keys[1].pub = keyDH.pub
  123. keys[1].secret
  124. .secKeyData = { -97, -62, -9, 18, 48, -96, -119, 7, 35, 50, 47, 58, -18, 66, -72, -59, 106, -75, -63, -29, -12, 6, 30, -85, 59, -116, 56, -36, 48, 6, -14, -46, -56, -3, -18, 16, 114, -125, -54, -100, 2, 83, -82, -67, 71, 122, -52, -5, -113, 21, -45, -104, -63, 49 } // byte[54]
  125. .iv = { -1, 124, 85, -94, 43, -56, 119, 103, 62, -109, -90, 110, 117, 116, 74, 115 } // byte[16]
  126. .pubKeyPacket = keyDH.pub
  127. .s2k.iv = { 18, 9, -128, 119, -66, -32, -43, -40 } // byte[8]
  128. .itCount = 96
  129. .algorithm = 2
  130. .protectionMode = -1
  131. .type = 3
  132. .s2kUsage = 254
  133. .encAlgorithm = 9
  134.  
  135.  
  136.  
  137. pgpPublicKeyRingECC
  138. .keys // size = 2
  139. [0].fingerprint = { -45, 118, -11, -14, -2, -50, 44, 67, -30, -28, 127, -115, 58, 43, -33, 106, -74, -65, 112, -49 } // byte[20]
  140. [0].idSigs[0][0].sigPck.unhashedData[0].data = { 58, 43, -33, 106, -74, -65, 112, -49 } // byte[8]
  141. .fingerprint = { -16, -109 } // byte[2]
  142. .hashedData
  143. [0].data = { 85, -24, 48, -22 } // SignatureCreationTime
  144. [1].data = { 1 } // Primary User ID
  145. [2].data = { 9, 8, 7, 3, 2, 1, 10 } // Preferred Algorithms
  146. [3].data = { 10, 9, 2, 3 } // Preferred Algorithms
  147. [4].data = { 0 } // Preferred Algorithms
  148. [5].data = { 1 } // Features
  149. [6].data = { 3 } // KeyFlags
  150. [0].idTrusts // All elements are null
  151. [0].ids[0].idData = { 107, 105, 114, 101, 46, 119, 105, 110, 56, 32, 60, 107, 105, 114, 101, 46, 119, 105, 110, 56, 64, 115, 99, 114, 121, 112, 116, 46, 98, 105, 122, 62 }
  152. [0].publicPk.key.e = 65537 // = 0x10001
  153. .key.n = 817662279674335977248488483214871644092522511224261082537928720302096524607942209125540665298671161765756642498561518114583543687730580960353697184264057889959310076245367633532858670876624764933904904285541825272083480710440489383036312524411736008606875990166340169220741384893034158027123817323413280206327513747406355096546514437056439438419502353325961576291113884291235405496107507787558319801555133568372724019659015439464075821116131633391543924034536806494698900320765421748465381631742794980872571108525183046911762310582611273609741533070770975107371743070593754029420877626255457592611363315432103597888372899361869889370958762203383918464124041525602432588669008593784327056561219919510524352099049446729046697512526106429000698363618202075167501502612210528222175721216404739259402572931824026426819535403659067565616604850275195670634217383959387140864997833598038200627117236465038661011530914542345403376292249480887475463655340456703164384030636604289314024640259901320598140197998949862878956518005883417499024063932085113625093127871786664172244751012901925573729718701996629451151450531110998155549703494724758339263592309219918673917352284945380403976817452380158349871893385573670846844504973326799916920339641 // big integer
  154. .algorithm = 1
  155. .time = 1441280214
  156. .validDays = 0
  157. .version = 4
  158. [0].keyID = 4191689527623905487
  159. [0].keyStrength = 4096
  160.  
  161. [1].fingerprint = { 49, -100, 68, 54, -76, -53, -64, -97, 126, -111, -67, -101, -91, 79, -12, 11, 82, -105, -92, 43 } // byte[20]
  162. [1].idSigs // empty ArrayList
  163. [1].idTrusts // empty ArrayList
  164. [1].ids // empty ArrayList
  165. [1].subSigs[0].sigPck.unhashedData[0].data = { 58, 43, -33, 106, -74, -65, 112, -49 }
  166. .fingerprint = { 64, 94 }
  167. .hashedData
  168. [0].data = { 85, -24, 49, 31 } // SignatureCreationTime
  169. [1].data = { 12 } // KeyFlags
  170. [2].data = { 0 } // PrimaryUserID
  171. [3].data = { 1 } // Features
  172. .signature[0].value = 751794824224450714124587025603220792666192785799840524221080690377568097660315239094972088330703330869870769282414066431176876813428142714477330207718499765680955051755144094968342478502328767099256455126771787118688009730882373301107471336236692661793185486652304491210176996289936774031491649312742791608568482685359525206881964434544440731879219514634958845835993436472103296311520412211233393243751105766644143929984997000410622531785053534486771739221409650678562558938670892327136972500067189601830746566436020453955146285937726647888158242620046707766542118666724530137290987919840924142118938688160229002964913987198319737917067012565557192488136204285790450128005550317905446095464987407002304542572717594980409263610063998370724712073829439685108202816125541356796253657533989860929703996095030321103187551152457147809033237466357898702982740844730667820363299892511259674707922115437115834620833525896859374327556823680540833139189286122592208557742837088621251364422361368663832912899198817444855156954187948167899324554189602231037582609457192538807250685887196106313983890014262163564143696109540445561185920583127822511545510402874906422489596184777175749026852525042221102644155173709321135874638032377576069301663341
  173. .version = 4
  174. .keyID = 4191689527623905487
  175. .creationTime = 1441280287000
  176. .signatureType = 24
  177. .hashAlgorithm = 2
  178. .keyAlgorithm = 1
  179. [1].publicPk.key.e = 65537
  180. .key.n = 781343970333245860649625584575220747569221335136676263568117451733789508423738750608775155859744854479565960959214267652117681289811422523953025215324796977686586708125002370314793463451848341243271824381646700434956302284196443782962378556524828803803960586596984572486950472279297669762135060562032715569629187794516768696436800601263984813236290185124051970166240713792916721478282250130244323869400011565204613301011109993313144844601200222874295794293412577885477816754011377453072368718702097496253533424244705707126852495965875198620299883078035702223775397693944753011706393554284669022964683746372685049261772474432703360371609319031679051915960773803337843552309156377598422397122279038463792471301273598468708773080220303889434245743700838129472228713048088339264422162833271399878354578452728762492876550854436707887629266036849608514784202535478949779485712504155471702147748724434581076599256643355760906696704317912021522850954175881744049008094863888378504247963861581634163258820029534914727229854082787152527991840931237945908600679774191855904335125999658576490015810155914447165663432780192436597891260908022542909564102222985372567098302496548806425831836953025533459396982004478060709004464617306629506395292089
  181. .algorithm = 1
  182. .time = 1441280276
  183. .validDays = 0
  184. .version = 4
  185. [1].keyID = -6534736204823813077
  186. [1].keyStrength = 4096
  187.  
  188.  
  189.  
  190.  
  191.  
  192. public void sendPgpPublicKeyRingECC(Account account, String email)
  193. PGPIdentitiy ident = new PGPIdentitiy();
  194. ident.email = email; // "kire.win8 <kire.win8@scrypt.biz>"
  195. ident.password = getPassword(account); // "U5BNtr_+-VlK69"
  196. ident.key = exportPgpPublicKeyRing(pgpPublicKeyRingECC);
  197. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  198. ArmoredOutputStream outputStream = new EPGPArmoredOutputStream(baos);
  199. keyRing.encode(outputStream);
  200. public void encode(OutputStream outStream) throws IOException {
  201. for(int i = 0; i != this.keys.size(); ++i) {
  202. PGPPublicKey k = (PGPPublicKey)this.keys.get(i);
  203. k.encode(outStream);
  204. public void encode(OutputStream outStream) throws IOException {
  205. out.writePacket(this.publicPk); // keyEdDSA.pub for i==0, keyDH.pub for i==1
  206. pOut.write(version); // version = 4
  207.  
  208. pOut.write((byte)(time >> 24)); // time = 1441276658
  209. pOut.write((byte)(time >> 16));
  210. pOut.write((byte)(time >> 8));
  211. pOut.write((byte)time);
  212.  
  213. if (version <= 3)
  214. {
  215. pOut.write((byte)(validDays >> 8));
  216. pOut.write((byte)validDays);
  217. }
  218.  
  219. pOut.write(algorithm); // 101
  220.  
  221. pOut.writeObject((BCPGObject)key); // keyHolder.mPublicKeySignature // 78316910109070494711848455011671547640019071078822912819699314060344903108075
  222. // writes: [6] = 1, [7] = 0, [8] = -83, [9] = 37 ... [39] = -21
  223. return bOut.toByteArray(); // whatever this means
  224.  
  225. if(this.subSigs == null) {
  226.  
  227. }
  228. }
  229. }
  230. }
  231.  
  232. outputStream.close();
  233. return baos.toString();
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259. -----BEGIN PGP PUBLIC KEY BLOCK-----
  260. Version: Research In Motion 1.0
  261.  
  262. mCgEVegi8mUBAK0lzN7LQmJAzXr8AfZh5rOVzNTP7XtpH8IHuj2H6IXrtCBraXJl
  263. LndpbjggPGtpcmUud2luOEBzY3J5cHQuYml6Poh4BBNlCgAgBQJV6CmtAhkBCAsJ
  264. CAcDAgEKBBUKCQgCFgACHgECGwMACgkQOflNAIRmG0vEcQD+J0mTjmhO4V8whZ4h
  265. 0Hn8ucSb0kPDIflNaP9E9zr5+ZoBAO84GLbUWIqVtyL4sYntp4UBPd4W7HVWxxqb
  266. GGXVYxoDuCgEVegcgmQBAKRR2WEJlghfiaGTtHzyzUTQS7mr8DIUO4aJTMFErV9l
  267. iHgEGGUKACAFAlXoKccCGQEICwkIBwMCAQoEFQoJCAIWAAIeAQIbAwAKCRA5+U0A
  268. hGYbS5zWAQDgttyUtR9oozWb+6ZOf5abPUClvLYbAyCiXfORlpys2AD/TDsr4t/i
  269. uVve7/ejo0PD14OX2yCAObOU4u+xWYe1SQM=
  270. =yCha
  271. -----END PGP PUBLIC KEY BLOCK-----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement