Ejemplo n.º 1
0
 public IdentityKeyPair(byte[] serialized)
 {
     try
     {
         StorageProtos.IdentityKeyPairStructure structure = StorageProtos.IdentityKeyPairStructure.ParseFrom(serialized);
         _publicKey  = new IdentityKey(structure.PublicKey.ToByteArray(), 0);
         _privateKey = Curve.DecodePrivatePoint(structure.PrivateKey.ToByteArray());
     }
     catch (InvalidProtocolBufferException e)
     {
         throw new InvalidKeyException(e);
     }
 }
        /**
         * Build a new session from a received {@link PreKeySignalMessage}.
         *
         * After a session is constructed in this way, the embedded {@link SignalMessage}
         * can be decrypted.
         *
         * @param message The received {@link PreKeySignalMessage}.
         * @throws org.whispersystems.libsignal.InvalidKeyIdException when there is no local
         *                                                             {@link org.whispersystems.libsignal.state.PreKeyRecord}
         *                                                             that corresponds to the PreKey ID in
         *                                                             the message.
         * @throws org.whispersystems.libsignal.InvalidKeyException when the message is formatted incorrectly.
         * @throws org.whispersystems.libsignal.UntrustedIdentityException when the {@link IdentityKey} of the sender is untrusted.
         */
        /*package*/
        internal May <uint> Process(SessionRecord sessionRecord, PreKeySignalMessage message)
        {
            uint        messageVersion   = message.GetMessageVersion();
            IdentityKey theirIdentityKey = message.GetIdentityKey();

            if (!_identityKeyStore.IsTrustedIdentity(_remoteAddress, theirIdentityKey))
            {
                throw new UntrustedIdentityException(_remoteAddress.GetName(), theirIdentityKey);
            }

            May <uint> unsignedPreKeyId = ProcessV3(sessionRecord, message);

            _identityKeyStore.SaveIdentity(_remoteAddress, theirIdentityKey);
            return(unsignedPreKeyId);
        }
 public UntrustedIdentityException(String name, IdentityKey key)
 {
     _name = name;
     _key  = key;
 }
Ejemplo n.º 4
0
 public IdentityKeyPair(IdentityKey publicKey, IEcPrivateKey privateKey)
 {
     _publicKey  = publicKey;
     _privateKey = privateKey;
 }