Refine search
r = new BigInteger(last[0], 16).toByteArray(); r = new BigInteger(last[0], 10).toByteArray(); assert (new String(Hex.toHexString(saltBytes)).toLowerCase() == "19457468657265756d205369676e6564204d6573736167653a0a3332");
utf16leBytes = password.getBytes("UTF-16LE"); digestBytes = md.digest(utf16leBytes); return new String(new String(Hex.encode(digestBytes)));
public static Optional<Integer> keyType(byte[] chunkEncryptionKey) { if (chunkEncryptionKey.length == 0) { logger.warn("-- keyType() - empty chunk key encryption key", Hex.toHexString(chunkEncryptionKey)); return Optional.empty(); } return Optional.of((int) chunkEncryptionKey[0]); }
public SecP192R1Curve() { super(q); this.infinity = new SecP192R1Point(this, null, null); this.a = fromBigInteger(new BigInteger(1, Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"))); this.b = fromBigInteger(new BigInteger(1, Hex.decode("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"))); this.order = new BigInteger(1, Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831")); this.cofactor = BigInteger.valueOf(1); this.coord = SecP192R1_DEFAULT_COORDS; }
@Override public String toString() { return "SECPrivateKey{" + "version=" + version + ", privateKey=" + Hex.toHexString(privateKey) + ", parameters=" + parameters.map(Hex::toHexString).orElse(null) + ", publicKey=" + publicKey.map(Hex::toHexString).orElse(null) + '}'; } }
static Optional<byte[]> unwrapKey(int wrap, byte[] kek, byte[] wpky) { if ((wrap & WRAP_DEVICE) != 0 || (wrap & WRAP_PASSCODE) == 0) { return Optional.empty(); } Optional<byte[]> key = RFC3394Wrap.unwrapAES(kek, wpky); // Should probably throw an exception here logger.debug("-- unwrapKey() - unwrap kek: 0x{} wpky: 0x{} > key: 0x{}", Hex.toHexString(kek), Hex.toHexString(wpky), key.map(Hex::toHexString).orElse("NULL")); return key; }
protected X9ECParameters createParameters() { BigInteger n = new BigInteger("E95E4A5F737059DC60DF5991D45029409E60FC09", 16); BigInteger h = new BigInteger("01", 16); ECCurve curve = configureCurve(new ECCurve.Fp( new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16), // q new BigInteger("340E7BE2A280EB74E2BE61BADA745D97E8F7C300", 16), // a new BigInteger("1E589A8595423412134FAA2DBDEC95C8D8675E58", 16), // b n, h)); return new X9ECParameters( curve, curve.decodePoint(Hex.decode("04BED5AF16EA3F6A4F62938C4631EB5AF7BDBCDBC31667CB477A1A8EC338F94741669C976316DA6321")), // G n, h); } };
static void checkPublicExportData(byte[] publicExportData, Optional<PublicKeyInfo> publicKeyInfo) { if (publicKeyInfo.isPresent()) { byte[] publicInfoExportedKeyData = publicKeyInfo.get().key(); if (Arrays.areEqual(publicExportData, publicInfoExportedKeyData)) { logger.debug("-- checkPublicExportData() - public export data match: {}", Hex.toHexString(publicExportData)); } else { logger.warn("-- checkPublicExportData() - public export data mismatch, supplied: {}, public key info: {}", Hex.toHexString(publicExportData), Hex.toHexString(publicInfoExportedKeyData)); } } }
void streamChunk(InputStream inputStream, int position, ChunkInfo chunkInfo, ChunkStore store) { byte[] checksum = chunkInfo.getChunkChecksum().toByteArray(); int chunkOffset = chunkInfo.getChunkOffset(); int chunkLength = chunkInfo.getChunkLength(); byte[] key = key(chunkInfo); logger.debug("-- streamChunk() - streaming chunk: 0x{}", Hex.toHexString(checksum)); positionedStream(inputStream, position, chunkOffset, chunkLength) .map(s -> boundedInputStream(s, chunkLength)) .map(s -> cipherInputStream(s, key, checksum)) .ifPresent(s -> copy(s, checksum, store)); }
protected X9ECParameters createParameters() { BigInteger n = new BigInteger("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16); BigInteger h = new BigInteger("01", 16); ECCurve curve = configureCurve(new ECCurve.Fp( new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16), // q new BigInteger("6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF", 16), // a new BigInteger("469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9", 16), // b n, h)); return new X9ECParameters( curve, new X9ECPoint(curve, Hex.decode("04C0A0647EAAB6A48753B033C56CB0F0900A2F5C4853375FD614B690866ABD5BB88B5F4828C1490002E6773FA2FA299B8F")), // G n, h); } };
private static BigInteger fromHex( String hex) { return new BigInteger(1, Hex.decode(hex)); }
static boolean testSignature(Digest digest, Optional<byte[]> signature) { return signature .map(c -> testSignature(digest, c)) .orElseGet(() -> { byte[] out = signature(digest); logger.debug("-- testSignature() - signature: 0x{}", Hex.toHexString(out)); return true; }); }
public static Optional<byte[]> unwrap(KeyBlob blob, KeyBag keyBag) { if (!Arrays.equals(blob.uuid(), keyBag.keyBagID().uuid())) { logger.warn("-- unwrap() - negative uuid match blob: 0x{} keybag: 0x{}", Hex.toHexString(blob.uuid()), Hex.toHexString(keyBag.keyBagID().uuid())); return Optional.empty(); } return doUnwrap(blob, keyBag); }
public Optional<byte[]> unwrap(ECPublicKey otherPublicKey, ECPrivateKey myPrivateKey, Digest digest, byte[] wrappedKey) { byte[] S = myPrivateKey.agreement(otherPublicKey); logger.debug("-- unwrap() - shared secret: 0x{}", Hex.toHexString(S)); byte[] salt = myPrivateKey.publicKey().point().xEncoded(); logger.debug("-- unwrap() - salt: 0x{}", Hex.toHexString(salt)); byte[] dk = RFC5869KDF.apply(S, salt, info, SHA256Digest::new, keyLength); logger.debug("-- unwrap() - dk: 0x{}", Hex.toHexString(salt)); Optional<byte[]> unwrapped = RFC3394Wrap.unwrapAES(dk, wrappedKey); logger.debug("-- unwrap() - unwrapped key: 0x{}", unwrapped.map(Hex::toHexString)); return unwrapped; } }
static ServiceKeySet backupBagPassword(NSDictionary escrowedData) { byte[] backupBagPassword = PListsLegacy.getAs(escrowedData, "BackupBagPassword", NSData.class).bytes(); logger.debug("-- backupBagPassword() - BackupBagPassword: 0x{}", Hex.toHexString(backupBagPassword)); return DERUtils.parse(backupBagPassword, KeySet::new) .flatMap(ServiceKeySetBuilder::build) .orElseThrow(() -> new IllegalArgumentException("failed to create backup bag key set")); }
BigInteger nonce, BigInteger expires) { nonce = nonce == null ? BigInteger.valueOf(exchange.getNonceFactory().createValue()) : nonce; contractAddress = contractAddress == null ? contractAddress().getAddress() : contractAddress; expires = expires == null ? BigInteger.valueOf(100000) : expires; exchange.getExchangeMetaData().getCurrencies().get(baseCurrency); exchange.getExchangeMetaData().getCurrencies().get(counterCurrency); .amountSell(amount_sell.toString()) .expires(expires) .r("0x" + new String(Hex.toHexString(r))) .s("0x" + new String(Hex.toHexString(s))) .v(BigInteger.valueOf(v & 0xffl));
static byte[] sessionKey(SRPClient srp, BlobA6 blob) { byte[] key = srp.verifyServerEvidenceMessage(blob.m2()) .orElseThrow(() -> new IllegalStateException("failed to verify SRP m2")); logger.debug("-- sessionKey() - session key: 0x{}", Hex.toHexString(key)); return key; }
byte[] generateClientCredentials(BigInteger a) { // Package private test injection point. this.a = a; logger.debug("-- generateClientCredentials() - a: 0x{}", a.toString(16)); ephemeralKeyA = SRPAssistant.generateEphemeralKeyA(N, g, a); logger.debug("-- generateClientCredentials() - ephemeral key A: 0x{}", Hex.toHexString(ephemeralKeyA)); return Arrays.copyOf(ephemeralKeyA, ephemeralKeyA.length); }
protected X9ECParameters createParameters() { byte[] S = Hex.decode("A335926AA319A27A1D00896A6773A4827ACDAC73"); ECCurve curve = configureCurve(new SecP384R1Curve()); ECPoint G = curve.decodePoint(Hex.decode("04" + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F")); return new X9ECParameters(curve, G, curve.getOrder(), curve.getCofactor(), S); } };