Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ECC key:
- class KeyHolder {
- byte[] mPrivateKey; // getPrivateKey()
- byte[] mPublicKeyDiffieHellman; // getPublicKeyDiffieHellman()
- byte[] mPublicKeySignature; // getPublicKeySignature()
- }
- Secure mail: kire.win8@scrypt.biz
- Activation Code: 3ed39d
- App Unlock Password: kire123
- keyPassphrase = 9xr9clUvdT7M0sKVA7eqkIuv
- keyUserId = kire.win8 <kire.win8@scrypt.biz>
- class AccountSetupCreatePGPFragment:
- performs async task:
- generateKeyRing();
- pgpKo.genEccKeyRing(userId, passphrase);
- pgpKo is class PGPKeyOpsEx
- userId = kire.win8 <kire.win8@scrypt.biz>
- passphrase = 9xr9clUvdT7M0sKVA7eqkIuv // char[24]
- KeyHolder keyHolder = generateKeyHolder();
- 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
- 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
- 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()
- 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)
- PGPKeyPair keyDH = generateEccKeyPair( PublicKeyAlgorithmTags.EXPERIMENTAL_1 = 100, new Curve25519PublicBCPGKey(keyHolder.getPublicKeyDiffieHellman()), keyHolder.getPrivateKey());
- algorithm publicKeyData secretKeyData
- class Curve25519PublicBCPGKey contains "private final byte[] key" which is a copy of keyHolder.mPublicKeyDiffieHellman
- PGPPublicKey publicKey = new PGPPublicKey( new PublicKeyPacket(algorithm, new Date(), publicKeyData), new BcKeyFingerprintCalculator());
- publicKey.publicPk
- .key = keyHolder.mPublicKeyDiffieHellman
- .algorithm = 100
- .time = 1441275010
- .validDays = 0
- .version = 4
- .fingerprint = { 100, 55, 111, -35, 65, 34, -55, -125, 41, 93, 76, -20, 70, -110, 46, 71, 72, 52, -13, -114 } // byte[20]
- .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);
- PGPPrivateKey privateKey = new PGPPrivateKey( publicKey.getKeyID(), publicKey.getPublicKeyPacket(), new ECSecretBCPGKey(new BigInteger(1, secretKeyData)));
- .keyID = 5085177812943696782 // same as above
- privateKey.publicKeyPacket = publicKey.publicPk // same as above
- privateKeyDataPacket.x.value = 65161615512395807035342817837557454990394607989690084773539878837707585031027 // generated from keyHolder.mPrivateKey
- keyDH.priv = privateKey
- keyDH.pub = publicKey
- PGPKeyPair keyEdDSA = generateEccKeyPair( PublicKeyAlgorithmTags.EXPERIMENTAL_2, new EdDSAPublicBCPGKey(keyHolder.getPublicKeySignature()), keyHolder.getPrivateKey());
- algorithm publicKeyData secretKeyData
- class EdDSAPublicBCPGKey contains "private final byte[] pk" which is a copy of keyHolder.mPublicKeySignature;
- it also contains "private static final EdDSANamedCurveSpec curveSpec" = { name = ""ed25519-sha-512", hashAlgo = "SHA-512", and other values }
- PGPPublicKey publicKey = new PGPPublicKey( new PublicKeyPacket(algorithm, new Date(), publicKeyData), new BcKeyFingerprintCalculator());
- publicKey.publicPk
- .key = keyHolder.mPublicKeySignature
- .algorithm = 101
- .time = 1441276658
- .validDays = 0
- .version = 4
- .fingerprint = { 69, 90, 61, -38, -12, -105, 54, 116, 27, 20, -81, 40, 57, -7, 77, 0, -124, 102, 27, 75 } // byte[20]
- .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);
- PGPPrivateKey privateKey = new PGPPrivateKey( publicKey.getKeyID(), publicKey.getPublicKeyPacket(), new ECSecretBCPGKey(new BigInteger(1, secretKeyData)));
- .keyID = 4177454793979468619 // same as above
- privateKey.publicKeyPacket = publicKey.publicPk // same as above
- privateKeyDataPacket.x.value = 65161615512395807035342817837557454990394607989690084773539878837707585031027 // generated from keyHolder.mPrivateKey (apparently same as keyDH's)
- keyEdDSA.priv = privateKey
- keyEdDSA.pub = publicKey
- pgpSignatureSubpacketGenerator // Next is setting up a PGPSignatureSubpacketGenerator
- pgpSignatureSubpacketGenerator.setPreferredSymmetricAlgorithms(false, encAlgs);
- pgpSignatureSubpacketGenerator.setPreferredHashAlgorithms(false, hashAlgs);
- pgpSignatureSubpacketGenerator.setPreferredCompressionAlgorithms(false, comprAlgs);
- pgpSignatureSubpacketGenerator.setFeature(false, Features.FEATURE_MODIFICATION_DETECTION);
- pgpSignatureSubpacketGenerator.setKeyFlags(false, KeyFlags.CERTIFY_OTHER + KeyFlags.SIGN_DATA);
- PGPSignatureSubpacketVector hashedPcks = pgpSignatureSubpacketGenerator.generate();
- // SHA1 is used for the checksum calculator; it's the only algorithm allowed.
- PGPKeyRingGenerator generator = new PGPKeyRingGenerator(
- PGPSignature.POSITIVE_CERTIFICATION, // 19
- keyEdDSA, // from above
- keyUserId, // ""kire.win8 <kire.win8@scrypt.biz>" - this is an unfortunately named string variable
- new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1),
- hashedPcks,
- null, // unhashedPcks,
- new EdDSAContentSigner.Builder(),
- new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256).build(keyPassphrase.toCharArray()));
- generator.addSubKey(keyDH);
- this.pgpPublicKeyRingECC = generator.generatePublicKeyRing();
- // PGPPublicKeyRing - This class has a list of keys "private List keys"
- keys[0].fingerprint = keyDH.pub.fingerprint
- keys[0].publicPk = keyDH.pub.publicPk
- keys[0].keyID = keyDH.pub.keyID
- this.pgpSecretKeyRingECC = generator.generateSecretKeyRing();
- // PGPSecretKeyRing - This class has 2 member variables "private List keys" and "List extraPubKeys"
- extraPubKeys = new ArrayList(); // this is just an empty list
- keys[0].pub = keyEdDSA.pub
- keys[0].secret
- .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]
- .iv = { -85, 19, 71, -32, 52, -106, 48, -121, 64, 32, -67, 111, -68, 75, -34, 14 } // byte[16]
- .pubKeyPacket = keyEdDSA.pub
- .s2k.iv = { 18, 9, -128, 119, -66, -32, -43, -40 } // byte[8]
- .itCount = 96
- .algorithm = 2
- .protectionMode = -1
- .type = 3
- .s2kUsage = 254
- .encAlgorithm = 9
- keys[1].pub = keyDH.pub
- keys[1].secret
- .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]
- .iv = { -1, 124, 85, -94, 43, -56, 119, 103, 62, -109, -90, 110, 117, 116, 74, 115 } // byte[16]
- .pubKeyPacket = keyDH.pub
- .s2k.iv = { 18, 9, -128, 119, -66, -32, -43, -40 } // byte[8]
- .itCount = 96
- .algorithm = 2
- .protectionMode = -1
- .type = 3
- .s2kUsage = 254
- .encAlgorithm = 9
- pgpPublicKeyRingECC
- .keys // size = 2
- [0].fingerprint = { -45, 118, -11, -14, -2, -50, 44, 67, -30, -28, 127, -115, 58, 43, -33, 106, -74, -65, 112, -49 } // byte[20]
- [0].idSigs[0][0].sigPck.unhashedData[0].data = { 58, 43, -33, 106, -74, -65, 112, -49 } // byte[8]
- .fingerprint = { -16, -109 } // byte[2]
- .hashedData
- [0].data = { 85, -24, 48, -22 } // SignatureCreationTime
- [1].data = { 1 } // Primary User ID
- [2].data = { 9, 8, 7, 3, 2, 1, 10 } // Preferred Algorithms
- [3].data = { 10, 9, 2, 3 } // Preferred Algorithms
- [4].data = { 0 } // Preferred Algorithms
- [5].data = { 1 } // Features
- [6].data = { 3 } // KeyFlags
- [0].idTrusts // All elements are null
- [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 }
- [0].publicPk.key.e = 65537 // = 0x10001
- .key.n = 817662279674335977248488483214871644092522511224261082537928720302096524607942209125540665298671161765756642498561518114583543687730580960353697184264057889959310076245367633532858670876624764933904904285541825272083480710440489383036312524411736008606875990166340169220741384893034158027123817323413280206327513747406355096546514437056439438419502353325961576291113884291235405496107507787558319801555133568372724019659015439464075821116131633391543924034536806494698900320765421748465381631742794980872571108525183046911762310582611273609741533070770975107371743070593754029420877626255457592611363315432103597888372899361869889370958762203383918464124041525602432588669008593784327056561219919510524352099049446729046697512526106429000698363618202075167501502612210528222175721216404739259402572931824026426819535403659067565616604850275195670634217383959387140864997833598038200627117236465038661011530914542345403376292249480887475463655340456703164384030636604289314024640259901320598140197998949862878956518005883417499024063932085113625093127871786664172244751012901925573729718701996629451151450531110998155549703494724758339263592309219918673917352284945380403976817452380158349871893385573670846844504973326799916920339641 // big integer
- .algorithm = 1
- .time = 1441280214
- .validDays = 0
- .version = 4
- [0].keyID = 4191689527623905487
- [0].keyStrength = 4096
- [1].fingerprint = { 49, -100, 68, 54, -76, -53, -64, -97, 126, -111, -67, -101, -91, 79, -12, 11, 82, -105, -92, 43 } // byte[20]
- [1].idSigs // empty ArrayList
- [1].idTrusts // empty ArrayList
- [1].ids // empty ArrayList
- [1].subSigs[0].sigPck.unhashedData[0].data = { 58, 43, -33, 106, -74, -65, 112, -49 }
- .fingerprint = { 64, 94 }
- .hashedData
- [0].data = { 85, -24, 49, 31 } // SignatureCreationTime
- [1].data = { 12 } // KeyFlags
- [2].data = { 0 } // PrimaryUserID
- [3].data = { 1 } // Features
- .signature[0].value = 751794824224450714124587025603220792666192785799840524221080690377568097660315239094972088330703330869870769282414066431176876813428142714477330207718499765680955051755144094968342478502328767099256455126771787118688009730882373301107471336236692661793185486652304491210176996289936774031491649312742791608568482685359525206881964434544440731879219514634958845835993436472103296311520412211233393243751105766644143929984997000410622531785053534486771739221409650678562558938670892327136972500067189601830746566436020453955146285937726647888158242620046707766542118666724530137290987919840924142118938688160229002964913987198319737917067012565557192488136204285790450128005550317905446095464987407002304542572717594980409263610063998370724712073829439685108202816125541356796253657533989860929703996095030321103187551152457147809033237466357898702982740844730667820363299892511259674707922115437115834620833525896859374327556823680540833139189286122592208557742837088621251364422361368663832912899198817444855156954187948167899324554189602231037582609457192538807250685887196106313983890014262163564143696109540445561185920583127822511545510402874906422489596184777175749026852525042221102644155173709321135874638032377576069301663341
- .version = 4
- .keyID = 4191689527623905487
- .creationTime = 1441280287000
- .signatureType = 24
- .hashAlgorithm = 2
- .keyAlgorithm = 1
- [1].publicPk.key.e = 65537
- .key.n = 781343970333245860649625584575220747569221335136676263568117451733789508423738750608775155859744854479565960959214267652117681289811422523953025215324796977686586708125002370314793463451848341243271824381646700434956302284196443782962378556524828803803960586596984572486950472279297669762135060562032715569629187794516768696436800601263984813236290185124051970166240713792916721478282250130244323869400011565204613301011109993313144844601200222874295794293412577885477816754011377453072368718702097496253533424244705707126852495965875198620299883078035702223775397693944753011706393554284669022964683746372685049261772474432703360371609319031679051915960773803337843552309156377598422397122279038463792471301273598468708773080220303889434245743700838129472228713048088339264422162833271399878354578452728762492876550854436707887629266036849608514784202535478949779485712504155471702147748724434581076599256643355760906696704317912021522850954175881744049008094863888378504247963861581634163258820029534914727229854082787152527991840931237945908600679774191855904335125999658576490015810155914447165663432780192436597891260908022542909564102222985372567098302496548806425831836953025533459396982004478060709004464617306629506395292089
- .algorithm = 1
- .time = 1441280276
- .validDays = 0
- .version = 4
- [1].keyID = -6534736204823813077
- [1].keyStrength = 4096
- public void sendPgpPublicKeyRingECC(Account account, String email)
- PGPIdentitiy ident = new PGPIdentitiy();
- ident.email = email; // "kire.win8 <kire.win8@scrypt.biz>"
- ident.password = getPassword(account); // "U5BNtr_+-VlK69"
- ident.key = exportPgpPublicKeyRing(pgpPublicKeyRingECC);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ArmoredOutputStream outputStream = new EPGPArmoredOutputStream(baos);
- keyRing.encode(outputStream);
- public void encode(OutputStream outStream) throws IOException {
- for(int i = 0; i != this.keys.size(); ++i) {
- PGPPublicKey k = (PGPPublicKey)this.keys.get(i);
- k.encode(outStream);
- public void encode(OutputStream outStream) throws IOException {
- out.writePacket(this.publicPk); // keyEdDSA.pub for i==0, keyDH.pub for i==1
- pOut.write(version); // version = 4
- pOut.write((byte)(time >> 24)); // time = 1441276658
- pOut.write((byte)(time >> 16));
- pOut.write((byte)(time >> 8));
- pOut.write((byte)time);
- if (version <= 3)
- {
- pOut.write((byte)(validDays >> 8));
- pOut.write((byte)validDays);
- }
- pOut.write(algorithm); // 101
- pOut.writeObject((BCPGObject)key); // keyHolder.mPublicKeySignature // 78316910109070494711848455011671547640019071078822912819699314060344903108075
- // writes: [6] = 1, [7] = 0, [8] = -83, [9] = 37 ... [39] = -21
- return bOut.toByteArray(); // whatever this means
- if(this.subSigs == null) {
- }
- }
- }
- }
- outputStream.close();
- return baos.toString();
- -----BEGIN PGP PUBLIC KEY BLOCK-----
- Version: Research In Motion 1.0
- mCgEVegi8mUBAK0lzN7LQmJAzXr8AfZh5rOVzNTP7XtpH8IHuj2H6IXrtCBraXJl
- LndpbjggPGtpcmUud2luOEBzY3J5cHQuYml6Poh4BBNlCgAgBQJV6CmtAhkBCAsJ
- CAcDAgEKBBUKCQgCFgACHgECGwMACgkQOflNAIRmG0vEcQD+J0mTjmhO4V8whZ4h
- 0Hn8ucSb0kPDIflNaP9E9zr5+ZoBAO84GLbUWIqVtyL4sYntp4UBPd4W7HVWxxqb
- GGXVYxoDuCgEVegcgmQBAKRR2WEJlghfiaGTtHzyzUTQS7mr8DIUO4aJTMFErV9l
- iHgEGGUKACAFAlXoKccCGQEICwkIBwMCAQoEFQoJCAIWAAIeAQIbAwAKCRA5+U0A
- hGYbS5zWAQDgttyUtR9oozWb+6ZOf5abPUClvLYbAyCiXfORlpys2AD/TDsr4t/i
- uVve7/ejo0PD14OX2yCAObOU4u+xWYe1SQM=
- =yCha
- -----END PGP PUBLIC KEY BLOCK-----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement