-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
Pkcs12SafeContentsBag.cs
37 lines (30 loc) · 1.15 KB
/
Pkcs12SafeContentsBag.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Formats.Asn1;
namespace System.Security.Cryptography.Pkcs
{
public sealed class Pkcs12SafeContentsBag : Pkcs12SafeBag
{
public Pkcs12SafeContents? SafeContents { get; private set; }
private Pkcs12SafeContentsBag(ReadOnlyMemory<byte> encoded)
: base(Oids.Pkcs12SafeContentsBag, encoded)
{
}
internal static Pkcs12SafeContentsBag Create(Pkcs12SafeContents copyFrom)
{
Debug.Assert(copyFrom != null);
Debug.Assert(copyFrom.ConfidentialityMode == Pkcs12ConfidentialityMode.None);
AsnWriter writer = copyFrom.Encode();
return Decode(writer.Encode());
}
internal static Pkcs12SafeContentsBag Decode(ReadOnlyMemory<byte> encodedValue)
{
Pkcs12SafeContents contents = new Pkcs12SafeContents(encodedValue);
return new Pkcs12SafeContentsBag(encodedValue)
{
SafeContents = contents
};
}
}
}