| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Certificates |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Elliptic Curve Cryptography (ECC) curve names. |
| | 11 | | /// </summary> |
| | 12 | | public readonly struct CertificateKeyCurveName : IEquatable<CertificateKeyCurveName> |
| | 13 | | { |
| | 14 | | private readonly string _value; |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Initializes a new instance of the <see cref="CertificateKeyCurveName"/> structure. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="value">The string value of the instance.</param> |
| | 20 | | public CertificateKeyCurveName(string value) |
| | 21 | | { |
| 8 | 22 | | _value = value ?? throw new ArgumentNullException(nameof(value)); |
| 8 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Gets the NIST P-256 elliptic curve, AKA SECG curve SECP256R1 |
| | 27 | | /// For more information, see <see href="https://docs.microsoft.com/azure/key-vault/keys/about-keys#curve-types" |
| | 28 | | /// </summary> |
| 4 | 29 | | public static CertificateKeyCurveName P256 { get; } = new CertificateKeyCurveName("P-256"); |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Gets the NIST P-384 elliptic curve, AKA SECG curve SECP384R1. |
| | 33 | | /// For more information, see <see href="https://docs.microsoft.com/azure/key-vault/keys/about-keys#curve-types" |
| | 34 | | /// </summary> |
| 0 | 35 | | public static CertificateKeyCurveName P384 { get; } = new CertificateKeyCurveName("P-384"); |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Gets the NIST P-521 elliptic curve, AKA SECG curve SECP521R1. |
| | 39 | | /// For more information, see <see href="https://docs.microsoft.com/azure/key-vault/keys/about-keys#curve-types" |
| | 40 | | /// </summary> |
| 0 | 41 | | public static CertificateKeyCurveName P521 { get; } = new CertificateKeyCurveName("P-521"); |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Gets the SECG SECP256K1 elliptic curve. |
| | 45 | | /// For more information, see <see href="https://docs.microsoft.com/azure/key-vault/keys/about-keys#curve-types" |
| | 46 | | /// </summary> |
| 0 | 47 | | public static CertificateKeyCurveName P256K { get; } = new CertificateKeyCurveName("P-256K"); |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Determines if two <see cref="CertificateKeyCurveName"/> values are the same. |
| | 51 | | /// </summary> |
| | 52 | | /// <param name="left">The first <see cref="CertificateKeyCurveName"/> to compare.</param> |
| | 53 | | /// <param name="right">The second <see cref="CertificateKeyCurveName"/> to compare.</param> |
| | 54 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur |
| 0 | 55 | | public static bool operator ==(CertificateKeyCurveName left, CertificateKeyCurveName right) => left.Equals(right |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// Determines if two <see cref="CertificateKeyCurveName"/> values are different. |
| | 59 | | /// </summary> |
| | 60 | | /// <param name="left">The first <see cref="CertificateKeyCurveName"/> to compare.</param> |
| | 61 | | /// <param name="right">The second <see cref="CertificateKeyCurveName"/> to compare.</param> |
| | 62 | | /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu |
| 0 | 63 | | public static bool operator !=(CertificateKeyCurveName left, CertificateKeyCurveName right) => !left.Equals(righ |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// Converts a string to a <see cref="CertificateKeyCurveName"/>. |
| | 67 | | /// </summary> |
| | 68 | | /// <param name="value">The string value to convert.</param> |
| 0 | 69 | | public static implicit operator CertificateKeyCurveName(string value) => new CertificateKeyCurveName(value); |
| | 70 | |
|
| | 71 | | /// <inheritdoc/> |
| | 72 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 73 | | public override bool Equals(object obj) => obj is CertificateKeyCurveName other && Equals(other); |
| | 74 | |
|
| | 75 | | /// <inheritdoc/> |
| 0 | 76 | | public bool Equals(CertificateKeyCurveName other) => string.Equals(_value, other._value, StringComparison.Ordina |
| | 77 | |
|
| | 78 | | /// <inheritdoc/> |
| | 79 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 80 | | public override int GetHashCode() => _value?.GetHashCode() ?? 0; |
| | 81 | |
|
| | 82 | | /// <inheritdoc/> |
| 2 | 83 | | public override string ToString() => _value; |
| | 84 | | } |
| | 85 | | } |