public bool IsValidIdentity(long recipientId,
                                    IdentityKey theirIdentity)
        {
            try
            {
                var query = conn.Table <Identity>().Where(v => v.RecipientId.Equals(recipientId));

                if (query.Count() > 0)
                {
                    var    identity           = query.First();
                    String serializedIdentity = identity.Key;
                    String mac = identity.Mac;


                    IdentityKey ourIdentity = new IdentityKey(Base64.decode(serializedIdentity), 0);

                    return(ourIdentity.Equals(theirIdentity));
                }
                else
                {
                    return(true);
                }
            }
            catch (IOException e) { return(false); }
            catch (InvalidKeyException e) { return(false); }
            catch (Exception e) { return(false); }
        }
Beispiel #2
0
        public bool SaveIdentity(SignalProtocolAddress address, IdentityKey identityKey)
        {
            IdentityKey existing;

            trustedKeys.TryGetValue(address, out existing);

            if (!identityKey.Equals(existing))
            {
                trustedKeys[address] = identityKey;
                return(true);
            }
            else
            {
                return(false);
            }
        }