public PrivateKey GenerateKeyPair(string description)
        {
            var cu      = new CryptUtility();
            var keyPair = cu.GenerateKeyPair(KeyEmail);

            var publicKeyId = UploadPublicKey(keyPair.PublicKey, description);

            var privateKey = new PrivateKey
            {
                ArmoredKey  = keyPair.PrivateKey,
                PublicKeyID = publicKeyId
            };

            return(privateKey);
        }
        public string GetKeycode(string packageId, PrivateKey privateKey)
        {
            var publicKeyId   = privateKey.PublicKeyID;
            var privateKeyStr = privateKey.ArmoredKey;

            var p = ConnectionStrings.Endpoints["getKeycode"].Clone();

            p.Path = p.Path.Replace("{publicKeyId}", publicKeyId);
            p.Path = p.Path.Replace("{packageId}", packageId);
            var response = _connection.Send <StandardResponse>(p);

            if (response.Response != APIResponse.SUCCESS)
            {
                throw new GettingKeycodeFailedException("Failed to get keycode: " + response.Message);
            }

            var encryptedKeycode = response.Message;

            var cu      = new CryptUtility();
            var keycode = cu.DecryptKeycode(privateKeyStr, encryptedKeycode);

            return(keycode);
        }
Пример #3
0
        private void DecryptFile(Stream encryptedFile, Stream decryptedFile)
        {
            var cu = new CryptUtility();

            cu.DecryptFile(decryptedFile, encryptedFile, GetDecryptionKey());
        }
Пример #4
0
        private string CreateChecksum()
        {
            var cu = new CryptUtility();

            return(cu.Pbkdf2(_pkgInfo.KeyCode, _pkgInfo.PackageCode, 1024));
        }