Example #1
0
        public LoginResponse Login(string email, string password)
        {
            CloseSyncAccount();

            Credentials   credentials = new Credentials(email, password);
            AccountClient account     = new AccountClient();

            return(account.Login(credentials, true).Result);
        }
Example #2
0
        public async Task SignIn(string email, string password)
        {
            SignOut();

            Credentials credentials = new Credentials(email, password);

            AccountClient account  = new AccountClient();
            LoginResponse response = await account.Login(credentials, true);

            KeysResponse keysResponse = await account.Keys(response.KeyFetchToken);

            string key = BinaryHelper.ToHexString(Credentials.DeriveHawkCredentials(response.KeyFetchToken, "keyFetchToken"));

            byte[] wrapKB = Credentials.UnbundleKeyFetchResponse(key, keysResponse.Bundle);

            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);

            TimeSpan duration = new TimeSpan(0, 1, 0, 0);

            CertificateSignResponse certificate = await account.CertificateSign(response.SessionToken, rsa, duration);

            string jwtToken  = JwtCryptoHelper.GetJwtToken(rsa);
            string assertion = JwtCryptoHelper.Bundle(jwtToken, certificate.Certificate);

            byte[] kB = BinaryHelper.Xor(wrapKB, credentials.UnwrapBKey);

            string syncClientState;

            using (SHA256 sha256 = new SHA256())
            {
                byte[] hash = sha256.ComputeHash(kB);
                syncClientState = BinaryHelper.ToHexString(hash.Take(16).ToArray());
            }

            TokenClient   tokenClient   = new TokenClient();
            TokenResponse tokenResponse = await tokenClient.GetSyncToken(assertion, syncClientState);

            storageClient = new StorageClient(tokenResponse.ApiEndpoint, tokenResponse.Key, tokenResponse.Id);

            BasicStorageObject cryptoKeys = await storageClient.GetStorageObject("crypto/keys");

            SyncKeys syncKeys = Crypto.DeriveKeys(kB);

            collectionKeys = Crypto.DecryptCollectionKeys(syncKeys, cryptoKeys);

            isSignedIn = true;
        }
Example #3
0
        public void VerifyLogin(string uid, string verificationCode)
        {
            AccountClient account = new AccountClient();

            account.Verify(uid, verificationCode);
        }