예제 #1
0
 internal override void WriteProperties(Utf8JsonWriter json)
 {
     if (KeyType != default)
     {
         json.WriteString(KeyTypePropertyNameBytes, KeyTypeExtensions.AsString(KeyType));
     }
     if (KeyOps != null)
     {
         json.WriteStartArray(KeyOpsPropertyNameBytes);
         foreach (var operation in KeyOps)
         {
             json.WriteStringValue(KeyOperationsExtensions.AsString(operation));
         }
         json.WriteEndArray();
     }
     if (!string.IsNullOrEmpty(CurveName))
     {
         json.WriteString(CurveNamePropertyNameBytes, CurveName);
     }
     if (N != null)
     {
         json.WriteString(NPropertyNameBytes, Base64Url.Encode(N));
     }
     if (E != null)
     {
         json.WriteString(EPropertyNameBytes, Base64Url.Encode(E));
     }
     if (DP != null)
     {
         json.WriteString(DPPropertyNameBytes, Base64Url.Encode(DP));
     }
     if (DQ != null)
     {
         json.WriteString(DQPropertyNameBytes, Base64Url.Encode(DQ));
     }
     if (QI != null)
     {
         json.WriteString(QIPropertyNameBytes, Base64Url.Encode(QI));
     }
     if (P != null)
     {
         json.WriteString(PPropertyNameBytes, Base64Url.Encode(P));
     }
     if (Q != null)
     {
         json.WriteString(QPropertyNameBytes, Base64Url.Encode(Q));
     }
     if (X != null)
     {
         json.WriteString(XPropertyNameBytes, Base64Url.Encode(X));
     }
     if (Y != null)
     {
         json.WriteString(YPropertyNameBytes, Base64Url.Encode(Y));
     }
     if (D != null)
     {
         json.WriteString(DPropertyNameBytes, Base64Url.Encode(D));
     }
     if (K != null)
     {
         json.WriteString(KPropertyNameBytes, Base64Url.Encode(K));
     }
     if (T != null)
     {
         json.WriteString(TPropertyNameBytes, Base64Url.Encode(T));
     }
 }
예제 #2
0
        internal override void ReadProperties(JsonElement json)
        {
            foreach (JsonProperty prop in json.EnumerateObject())
            {
                switch (prop.Name)
                {
                case KeyIdPropertyName:
                    KeyId = prop.Value.GetString();
                    break;

                case KeyTypePropertyName:
                    KeyType = KeyTypeExtensions.ParseFromString(prop.Value.GetString());
                    break;

                case KeyOpsPropertyName:
                    foreach (var element in prop.Value.EnumerateArray())
                    {
                        KeyOps.Add(KeyOperationsExtensions.ParseFromString(element.ToString()));
                    }
                    break;

                case CurveNamePropertyName:
                    CurveName = prop.Value.GetString();
                    break;

                case NPropertyName:
                    N = Base64Url.Decode(prop.Value.GetString());
                    break;

                case EPropertyName:
                    E = Base64Url.Decode(prop.Value.GetString());
                    break;

                case DPPropertyName:
                    DP = Base64Url.Decode(prop.Value.GetString());
                    break;

                case DQPropertyName:
                    DQ = Base64Url.Decode(prop.Value.GetString());
                    break;

                case QIPropertyName:
                    QI = Base64Url.Decode(prop.Value.GetString());
                    break;

                case PPropertyName:
                    P = Base64Url.Decode(prop.Value.GetString());
                    break;

                case QPropertyName:
                    Q = Base64Url.Decode(prop.Value.GetString());
                    break;

                case XPropertyName:
                    X = Base64Url.Decode(prop.Value.GetString());
                    break;

                case YPropertyName:
                    Y = Base64Url.Decode(prop.Value.GetString());
                    break;

                case DPropertyName:
                    D = Base64Url.Decode(prop.Value.GetString());
                    break;

                case KPropertyName:
                    K = Base64Url.Decode(prop.Value.GetString());
                    break;

                case TPropertyName:
                    T = Base64Url.Decode(prop.Value.GetString());
                    break;
                }
            }
        }