| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | namespace Microsoft.Azure.KeyVault.WebKey |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Elliptic Curve Cryptography (ECC) curve names. |
| | 9 | | /// </summary> |
| | 10 | | public static class JsonWebKeyCurveName |
| | 11 | | { |
| | 12 | | public const string P256 = "P-256"; |
| | 13 | | public const string P384 = "P-384"; |
| | 14 | | public const string P521 = "P-521"; |
| | 15 | | public const string P256K = "P-256K"; |
| | 16 | |
|
| 0 | 17 | | private static readonly string[] _allCurves = {P256, P384, P521, P256K}; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// All curves for EC. Use clone to avoid FxCop violation |
| | 21 | | /// </summary> |
| 0 | 22 | | public static string[] AllCurves => (string[]) _allCurves.Clone(); |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Returns the required size, in bytes, of each key parameters (X, Y and D), or -1 if the curve is unsupported. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="curve">The curve for which key parameter size is required.</param> |
| | 28 | | /// <returns></returns> |
| | 29 | | public static int GetKeyParameterSize( string curve ) |
| | 30 | | { |
| | 31 | | switch ( curve ) |
| | 32 | | { |
| | 33 | | case P256: |
| | 34 | | case P256K: |
| 72 | 35 | | return 32; |
| | 36 | |
|
| | 37 | | case P384: |
| 22 | 38 | | return 48; |
| | 39 | |
|
| | 40 | | case P521: |
| 22 | 41 | | return 66; |
| | 42 | |
|
| | 43 | | default: |
| 0 | 44 | | return -1; |
| | 45 | | } |
| | 46 | | } |
| | 47 | | } |
| | 48 | | } |