public Binder asBinder() { return Binder.fromKeysValues( "connectMessage", getConnectMessage(), // "privateKey", privateKey.pack(), "sessionKey", getSessionKey().pack(), "sessionId", getSessionId() // "nodePublicKey", nodePublicKey.pack() ); }
private void createSessionKey() throws EncryptionError { if (sessionKey == null) { sessionKey = new SymmetricKey(); Binder data = Binder.fromKeysValues( "sk", sessionKey.pack() ); encryptedAnswer = publicKey.encrypt(Boss.pack(data)); } }
"version", MY_VERSION, "public_key", myKey.getPublicKey().pack(), "session_key", mySessionKey.pack(), "nonce", myNonce ).waitSuccess()
byte[] packedMainKey = mainKey.pack();
private Object onHello(Binder params) throws IOException { // Checking protocol and version if (!params.getStringOrThrow("protocol").equals("bitrusted")) throw new IOException("unsupported protocol, needs bitrusted'"); if (params.getIntOrThrow("version") > MY_VERSION) throw new IOException("unsupported protocol version, needs <= " + MY_VERSION); // checking parameters byte[] nonce = params.getBinaryOrThrow("nonce"); setRemoteKey(params.getBinaryOrThrow("public_key")); remoteSessionKey = new SymmetricKey(params.getBinaryOrThrow("session_key")); // We intentionally do not use capsule here to improve network speed byte[] result = Boss.pack(Binder.fromKeysValues( "session_key", mySessionKey.pack(), "nonce", nonce) ); result = remoteKey.encrypt(result); byte[] signature = myKey.sign(result, HashType.SHA256); ready.fire(null); // log.d(toString() + " returning hello"); return Binder.fromKeysValues( "data", result, "signature", signature, "public_key", myKey.getPublicKey().pack() ); }