/// <summary> /// Signs a hash and then verifies the signature /// </summary> /// <param name="keyId"> a global key identifier of the key to get </param> private static void SignVerify(KeyBundle key) { KeyOperationResult signature; var algorithm = inputValidator.GetSignAlgorithm(); var digest = inputValidator.GetDigestHash(); string keyVersion = inputValidator.GetKeyVersion(); if (keyVersion != string.Empty) { var vaultAddress = inputValidator.GetVaultAddress(); string keyName = inputValidator.GetKeyName(true); signature = keyVaultClient.SignAsync(vaultAddress, keyName, keyVersion, algorithm, digest).GetAwaiter().GetResult(); } else { // If the key is not initialized get the key id from args var keyId = (key != null) ? key.Key.Kid : inputValidator.GetKeyId(); // Create a signature signature = keyVaultClient.SignAsync(keyId, algorithm, digest).GetAwaiter().GetResult(); } Console.Out.WriteLine(string.Format("The signature is created using key id {0} and algorithm {1} ", signature.Kid, algorithm)); // Verify the signature bool isVerified = keyVaultClient.VerifyAsync(signature.Kid, algorithm, digest, signature.Result).GetAwaiter().GetResult(); Console.Out.WriteLine(string.Format("The signature is {0} verified!", isVerified ? "" : "not ")); }