-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from aseigler/master
* Added PeterO.Cbor as local project to close #7 * Added Chaos.NaCl as local project for EdDSA support * Added Yubico root and known aaguid to custom metadata to support trust path verification for at least some Yubico devices
- Loading branch information
Showing
155 changed files
with
31,882 additions
and
1,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard1.0</TargetFramework> | ||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | ||
<Version>3.4.0-beta1</Version> | ||
<Owners>Peter Occil</Owners> | ||
<Description>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049.</Description> | ||
<Summary>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049. </Summary> | ||
<Copyright>Written by Peter O. in 2013-2018. Any copyright is released to the Public Domain.</Copyright> | ||
<Authors>Peter Occil</Authors> | ||
<PackageId>PeterO.Cbor</PackageId> | ||
<PackageLicenseUrl>http:https://creativecommons.org/publicdomain/zero/1.0/</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/peteroupc/CBOR</PackageProjectUrl> | ||
<PackageReleaseNotes> | ||
Version 3.4.0-beta1: | ||
|
||
- Improved implemenation of new ToObject method. | ||
- Bugs in multidimensional array serialization by FromObject were fixed. | ||
- URI parsing restored to 3.0 version for backward compatibility. | ||
- Remove method disallows null for backward compatibility. | ||
- ICBORObjectConverter renamed to ICBORToFromConverter. | ||
- Several APIs were obsoleted. | ||
|
||
Version 3.4.0-alpha1: | ||
|
||
- Add ToObject method for deserializing CBOR objects. | ||
- Add ICBORObjectConverter interface. | ||
- Add HasMostOuterTag method to CBORObject class. | ||
- Add CTAP2 canonicalization support to CBOR object encoding. | ||
- Added examples in several places in documentation. | ||
|
||
</PackageReleaseNotes> | ||
<PackageTags>cbor data serialization binary json</PackageTags> | ||
<SignAssembly>false</SignAssembly> | ||
<AssemblyOriginatorKeyFile>PeterO.snk</AssemblyOriginatorKeyFile> | ||
<Title>CBOR (Concise Binary Object Representation)</Title> | ||
<PackOnBuild>true</PackOnBuild> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DocumentationFile>bin\Debug\netstandard1.0\CBOR.xml</DocumentationFile> | ||
<CustomCommands> | ||
<CustomCommands> | ||
<Command> | ||
<type>Custom</type> | ||
<name>Signing Workaround</name> | ||
<command>sn -R bin/Debug/netstandard1.0/CBOR.dll PeterO.snk</command> | ||
<workingdir>${ProjectDir}</workingdir> | ||
<externalConsole>True</externalConsole> | ||
</Command> | ||
</CustomCommands> | ||
</CustomCommands> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType></DebugType> | ||
<DocumentationFile>bin\Release\netstandard1.0\CBOR.xml</DocumentationFile> | ||
<CustomCommands> | ||
<CustomCommands> | ||
<Command> | ||
<type>Custom</type> | ||
<name>Signing Workaround</name> | ||
<command>sn -R bin/Release/netstandard1.0/CBOR.dll PeterO.snk</command> | ||
<workingdir>${ProjectDir}</workingdir> | ||
<externalConsole>True</externalConsole> | ||
</Command> | ||
</CustomCommands> | ||
</CustomCommands> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="PeterO.Numbers" Version="1.1.2" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
Written by Peter O. in 2013. | ||
Any copyright is dedicated to the Public Domain. | ||
http:https://creativecommons.org/publicdomain/zero/1.0/ | ||
If you like this, you should donate to Peter O. | ||
at: http:https://peteroupc.github.io/ | ||
*/ | ||
using System; | ||
using PeterO.Numbers; | ||
|
||
namespace PeterO { | ||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="T:PeterO.BigInteger"]/*'/> | ||
[Obsolete( | ||
"Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.")] | ||
public sealed partial class BigInteger : IComparable<BigInteger>, | ||
IEquatable<BigInteger> { | ||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="F:PeterO.BigInteger.ONE"]/*'/> | ||
#if CODE_ANALYSIS | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage( | ||
"Microsoft.Security", | ||
"CA2104", | ||
Justification = "BigInteger is immutable")] | ||
#endif | ||
|
||
[Obsolete("Use EInteger from PeterO.Numbers/com.upokecenter.numbers.")] | ||
public static readonly BigInteger ONE = new BigInteger(EInteger.One); | ||
|
||
private static readonly BigInteger ValueOneValue = new | ||
BigInteger(EInteger.One); | ||
|
||
private readonly EInteger ei; | ||
|
||
internal BigInteger(EInteger ei) { | ||
if (ei == null) { | ||
throw new ArgumentNullException(nameof(ei)); | ||
} | ||
this.ei = ei; | ||
} | ||
|
||
internal static BigInteger ToLegacy(EInteger ei) { | ||
return new BigInteger(ei); | ||
} | ||
|
||
internal static EInteger FromLegacy(BigInteger bei) { | ||
return bei.Ei; | ||
} | ||
|
||
private static readonly BigInteger ValueZeroValue = new | ||
BigInteger(EInteger.Zero); | ||
|
||
internal EInteger Ei { | ||
get { | ||
return this.ei; | ||
} | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.fromBytes(System.Byte[],System.Boolean)"]/*'/> | ||
public static BigInteger fromBytes(byte[] bytes, bool littleEndian) { | ||
return new BigInteger(EInteger.FromBytes(bytes, littleEndian)); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.fromRadixString(System.String,System.Int32)"]/*'/> | ||
public static BigInteger fromRadixString(string str, int radix) { | ||
return new BigInteger(EInteger.FromRadixString(str, radix)); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.fromString(System.String)"]/*'/> | ||
public static BigInteger fromString(string str) { | ||
return new BigInteger(EInteger.FromString(str)); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.valueOf(System.Int64)"]/*'/> | ||
public static BigInteger valueOf(long longerValue) { | ||
return new BigInteger(EInteger.FromInt64(longerValue)); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.bitLength"]/*'/> | ||
public int bitLength() { | ||
return this.Ei.GetSignedBitLength(); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.Equals(System.Object)"]/*'/> | ||
public override bool Equals(object obj) { | ||
var bi = obj as BigInteger; | ||
return (bi == null) ? false : this.Ei.Equals(bi.Ei); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.GetHashCode"]/*'/> | ||
public override int GetHashCode() { | ||
return this.Ei.GetHashCode(); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.toBytes(System.Boolean)"]/*'/> | ||
public byte[] toBytes(bool littleEndian) { | ||
return this.Ei.ToBytes(littleEndian); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.toRadixString(System.Int32)"]/*'/> | ||
public string toRadixString(int radix) { | ||
return this.Ei.ToRadixString(radix); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.ToString"]/*'/> | ||
public override string ToString() { | ||
return this.Ei.ToString(); | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.CompareTo(PeterO.BigInteger)"]/*'/> | ||
public int CompareTo(BigInteger other) { | ||
return this.Ei.CompareTo(other == null ? null : other.Ei); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Written by Peter O. in 2013. | ||
Any copyright is dedicated to the Public Domain. | ||
http:https://creativecommons.org/publicdomain/zero/1.0/ | ||
If you like this, you should donate to Peter O. | ||
at: http:https://peteroupc.github.io/ | ||
*/ | ||
using System; | ||
using PeterO.Numbers; | ||
|
||
namespace PeterO { | ||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="T:PeterO.BigInteger"]/*'/> | ||
public sealed partial class BigInteger { | ||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="P:PeterO.BigInteger.Zero"]/*'/> | ||
[CLSCompliant(false)] [Obsolete( | ||
"Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.")] | ||
public static BigInteger Zero { | ||
get { | ||
return ValueZeroValue; | ||
} | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="P:PeterO.BigInteger.One"]/*'/> | ||
[CLSCompliant(false)] [Obsolete( | ||
"Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.")] | ||
public static BigInteger One { | ||
get { | ||
return ValueOneValue; | ||
} | ||
} | ||
|
||
/// <include file='../docs.xml' | ||
/// path='docs/doc[@name="M:PeterO.BigInteger.Equals(PeterO.BigInteger)"]/*'/> | ||
[Obsolete( | ||
"Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.")] | ||
public bool Equals(BigInteger other) { | ||
return this.Equals((object)other); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
Written by Peter O. in 2014. | ||
Any copyright is dedicated to the Public Domain. | ||
http:https://creativecommons.org/publicdomain/zero/1.0/ | ||
If you like this, you should donate to Peter O. | ||
at: http:https://peteroupc.github.io/ | ||
*/ | ||
using System; | ||
using System.Text; | ||
|
||
namespace PeterO.Cbor { | ||
internal static class Base64 { | ||
private const string Base64URL = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; | ||
|
||
private const string Base64Classic = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
|
||
public static void WriteBase64( | ||
StringOutput writer, | ||
byte[] data, | ||
int offset, | ||
int count, | ||
bool padding) { | ||
WriteBase64(writer, data, offset, count, true, padding); | ||
} | ||
|
||
public static void WriteBase64URL( | ||
StringOutput writer, | ||
byte[] data, | ||
int offset, | ||
int count, | ||
bool padding) { | ||
WriteBase64(writer, data, offset, count, false, padding); | ||
} | ||
|
||
private static void WriteBase64( | ||
StringOutput writer, | ||
byte[] data, | ||
int offset, | ||
int count, | ||
bool classic, | ||
bool padding) { | ||
if (writer == null) { | ||
throw new ArgumentNullException(nameof(writer)); | ||
} | ||
if (offset < 0) { | ||
throw new ArgumentException("offset (" + offset + ") is less than " + | ||
"0 "); | ||
} | ||
if (offset > data.Length) { | ||
throw new ArgumentException("offset (" + offset + ") is more than " + | ||
data.Length); | ||
} | ||
if (count < 0) { | ||
throw new ArgumentException("count (" + count + ") is less than " + | ||
"0 "); | ||
} | ||
if (count > data.Length) { | ||
throw new ArgumentException("count (" + count + ") is more than " + | ||
data.Length); | ||
} | ||
if (data.Length - offset < count) { | ||
throw new ArgumentException("data's length minus " + offset + " (" + | ||
(data.Length - offset) + ") is less than " + count); | ||
} | ||
string alphabet = classic ? Base64Classic : Base64URL; | ||
int length = offset + count; | ||
int i = offset; | ||
var buffer = new char[4]; | ||
for (i = offset; i < (length - 2); i += 3) { | ||
buffer[0] = (char)alphabet[(data[i] >> 2) & 63]; | ||
buffer[1] = (char)alphabet[((data[i] & 3) << 4) + | ||
((data[i + 1] >> 4) & 15)]; | ||
buffer[2] = (char)alphabet[((data[i + 1] & 15) << 2) + ((data[i + | ||
2] >> 6) & 3)]; | ||
buffer[3] = (char)alphabet[data[i + 2] & 63]; | ||
writer.WriteCodePoint((int)buffer[0]); | ||
writer.WriteCodePoint((int)buffer[1]); | ||
writer.WriteCodePoint((int)buffer[2]); | ||
writer.WriteCodePoint((int)buffer[3]); | ||
} | ||
int lenmod3 = count % 3; | ||
if (lenmod3 != 0) { | ||
i = length - lenmod3; | ||
buffer[0] = (char)alphabet[(data[i] >> 2) & 63]; | ||
if (lenmod3 == 2) { | ||
buffer[1] = (char)alphabet[((data[i] & 3) << 4) + ((data[i + 1] >> | ||
4) & 15)]; | ||
buffer[2] = (char)alphabet[(data[i + 1] & 15) << 2]; | ||
writer.WriteCodePoint((int)buffer[0]); | ||
writer.WriteCodePoint((int)buffer[1]); | ||
writer.WriteCodePoint((int)buffer[2]); | ||
if (padding) { | ||
writer.WriteCodePoint((int)'='); | ||
} | ||
} else { | ||
buffer[1] = (char)alphabet[(data[i] & 3) << 4]; | ||
writer.WriteCodePoint((int)buffer[0]); | ||
writer.WriteCodePoint((int)buffer[1]); | ||
if (padding) { | ||
writer.WriteCodePoint((int)'='); | ||
writer.WriteCodePoint((int)'='); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.