| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Security.KeyVault.Keys.Cryptography; |
| | 5 | |
|
| | 6 | | namespace Azure.Security.KeyVault.Keys |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Model factory that enables mocking for the Key Vault Cryptography library. |
| | 10 | | /// </summary> |
| | 11 | | public static class CryptographyModelFactory |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Initializes a new instance of the <see cref="Cryptography.DecryptResult"/> for mocking purposes. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="keyId">Sets the <see cref="DecryptResult.KeyId"/> property.</param> |
| | 17 | | /// <param name="plaintext">Sets the <see cref="DecryptResult.Plaintext"/> property.</param> |
| | 18 | | /// <param name="algorithm">Sets the <see cref="DecryptResult.Algorithm"/> property.</param> |
| | 19 | | /// <returns>A new instance of the <see cref="Cryptography.DecryptResult"/> for mocking purposes.</returns> |
| 0 | 20 | | public static DecryptResult DecryptResult(string keyId = default, byte[] plaintext = default, EncryptionAlgorith |
| 0 | 21 | | { |
| 0 | 22 | | KeyId = keyId, |
| 0 | 23 | | Plaintext = plaintext, |
| 0 | 24 | | Algorithm = algorithm, |
| 0 | 25 | | }; |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Initializes a new instance of the <see cref="Cryptography.EncryptResult"/> for mocking purposes. |
| | 29 | | /// </summary> |
| | 30 | | /// <param name="keyId">Sets the <see cref="EncryptResult.KeyId"/> property.</param> |
| | 31 | | /// <param name="ciphertext">Sets the <see cref="EncryptResult.Ciphertext"/> property.</param> |
| | 32 | | /// <param name="algorithm">Sets the <see cref="EncryptResult.Algorithm"/> property.</param> |
| | 33 | | /// <returns>A new instance of the <see cref="Cryptography.EncryptResult"/> for mocking purposes.</returns> |
| 0 | 34 | | public static EncryptResult EncryptResult(string keyId = default, byte[] ciphertext = default, EncryptionAlgorit |
| 0 | 35 | | { |
| 0 | 36 | | KeyId = keyId, |
| 0 | 37 | | Ciphertext = ciphertext, |
| 0 | 38 | | Algorithm = algorithm, |
| 0 | 39 | | }; |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Initializes a new instance of the <see cref="Cryptography.SignResult"/> for mocking purposes. |
| | 43 | | /// </summary> |
| | 44 | | /// <param name="keyId">Sets the <see cref="SignResult.KeyId"/> property.</param> |
| | 45 | | /// <param name="signature">Sets the <see cref="SignResult.Signature"/> property.</param> |
| | 46 | | /// <param name="algorithm">Sets the <see cref="SignResult.Algorithm"/> property.</param> |
| | 47 | | /// <returns>A new instance of the <see cref="Cryptography.SignResult"/> for mocking purposes.</returns> |
| 0 | 48 | | public static SignResult SignResult(string keyId = default, byte[] signature = default, SignatureAlgorithm algor |
| 0 | 49 | | { |
| 0 | 50 | | KeyId = keyId, |
| 0 | 51 | | Signature = signature, |
| 0 | 52 | | Algorithm = algorithm, |
| 0 | 53 | | }; |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Initializes a new instance of the <see cref="Cryptography.UnwrapResult"/> for mocking purposes. |
| | 57 | | /// </summary> |
| | 58 | | /// <param name="keyId">Sets the <see cref="UnwrapResult.KeyId"/> property.</param> |
| | 59 | | /// <param name="key">Sets the <see cref="UnwrapResult.Key"/> property.</param> |
| | 60 | | /// <param name="algorithm">Sets the <see cref="UnwrapResult.Algorithm"/> property.</param> |
| | 61 | | /// <returns>A new instance of the <see cref="Cryptography.UnwrapResult"/> for mocking purposes.</returns> |
| 0 | 62 | | public static UnwrapResult UnwrapResult(string keyId = default, byte[] key = default, KeyWrapAlgorithm algorithm |
| 0 | 63 | | { |
| 0 | 64 | | KeyId = keyId, |
| 0 | 65 | | Key = key, |
| 0 | 66 | | Algorithm = algorithm, |
| 0 | 67 | | }; |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// Initializes a new instance of the <see cref="Cryptography.VerifyResult"/> for mocking purposes. |
| | 71 | | /// </summary> |
| | 72 | | /// <param name="keyId">Sets the <see cref="VerifyResult.KeyId"/> property.</param> |
| | 73 | | /// <param name="isValid">Sets the <see cref="VerifyResult.IsValid"/> property.</param> |
| | 74 | | /// <param name="algorithm">Sets the <see cref="VerifyResult.Algorithm"/> property.</param> |
| | 75 | | /// <returns>A new instance of the <see cref="Cryptography.VerifyResult"/> for mocking purposes.</returns> |
| 0 | 76 | | public static VerifyResult VerifyResult(string keyId = default, bool isValid = default, SignatureAlgorithm algor |
| 0 | 77 | | { |
| 0 | 78 | | KeyId = keyId, |
| 0 | 79 | | IsValid = isValid, |
| 0 | 80 | | Algorithm = algorithm, |
| 0 | 81 | | }; |
| | 82 | |
|
| | 83 | | /// <summary> |
| | 84 | | /// Initializes a new instance of the <see cref="Cryptography.WrapResult"/> for mocking purposes. |
| | 85 | | /// </summary> |
| | 86 | | /// <param name="keyId">Sets the <see cref="WrapResult.KeyId"/> property.</param> |
| | 87 | | /// <param name="key">Sets the <see cref="WrapResult.EncryptedKey"/> property.</param> |
| | 88 | | /// <param name="algorithm">Sets the <see cref="WrapResult.Algorithm"/> property.</param> |
| | 89 | | /// <returns>A new instance of the <see cref="Cryptography.WrapResult"/> for mocking purposes.</returns> |
| 0 | 90 | | public static WrapResult WrapResult(string keyId = default, byte[] key = default, KeyWrapAlgorithm algorithm = d |
| 0 | 91 | | { |
| 0 | 92 | | KeyId = keyId, |
| 0 | 93 | | EncryptedKey = key, |
| 0 | 94 | | Algorithm = algorithm, |
| 0 | 95 | | }; |
| | 96 | | } |
| | 97 | | } |