-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adjust OID4VP signatures Signed-off-by: Kevin <[email protected]> * adjust ICredential Signed-off-by: Kevin <[email protected]> * implement base64url type Signed-off-by: Kevin <[email protected]> * refactorings Signed-off-by: Kevin <[email protected]> * adjust mdoc lib folder structure Signed-off-by: Kevin <[email protected]> * rename namespaces to issuer namespaces Signed-off-by: Kevin <[email protected]> * security stuff in core project Signed-off-by: Kevin <[email protected]> * add keyId to MdocRecord Signed-off-by: Kevin <[email protected]> * add comments to ClientMetadata.cs Signed-off-by: Kevin <[email protected]> * implement mdoc presentation Signed-off-by: Kevin <[email protected]> * implement mdoc oid4vp Signed-off-by: Kevin <[email protected]> * adjust tests Signed-off-by: Kevin <[email protected]> * some cleanup Signed-off-by: Kevin <[email protected]> * bump dotnet version in pipeline Signed-off-by: Kevin <[email protected]> * bump nuget version in pipeline Signed-off-by: Kevin <[email protected]> * bump nuget version in pipeline Signed-off-by: Kevin <[email protected]> * bump nuget version in pipeline Signed-off-by: Kevin <[email protected]> * minor refactor Signed-off-by: Kevin <[email protected]> * fix merge Signed-off-by: Kevin <[email protected]> * rename SdJwtSignerService to SdJwtSigner Signed-off-by: Kevin <[email protected]> * introduce raw signature Signed-off-by: Kevin <[email protected]> * fix merge Signed-off-by: Kevin <[email protected]> * adjust cose signature Signed-off-by: Kevin <[email protected]> * add string funcs Signed-off-by: Kevin <[email protected]> --------- Signed-off-by: Kevin <[email protected]>
- Loading branch information
Showing
122 changed files
with
2,511 additions
and
1,418 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 |
---|---|---|
|
@@ -38,15 +38,17 @@ jobs: | |
echo "APP_VERSION=$VERSION$SUFFIX" >> $GITHUB_ENV | ||
- name: Setup NuGet | ||
uses: NuGet/[email protected] | ||
uses: NuGet/setup-nuget@v2 | ||
with: | ||
nuget-version: 6.10.2 | ||
|
||
- name: Restore dependencies | ||
run: nuget restore $SOLUTION | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 3.1.* | ||
dotnet-version: 8.0.* | ||
|
||
# - name: Install libindy library | ||
# run: | | ||
|
9 changes: 0 additions & 9 deletions
9
src/Hyperledger.Aries/Storage/Models/Interfaces/ICredential.cs
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
using Microsoft.IdentityModel.Tokens; | ||
|
||
namespace WalletFramework.Core.Base64Url; | ||
|
||
public readonly struct Base64UrlString | ||
{ | ||
private string Value { get; } | ||
|
||
private Base64UrlString(string value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public override string ToString() => Value; | ||
|
||
public static implicit operator string(Base64UrlString base64UrlString) => base64UrlString.ToString(); | ||
|
||
public static Base64UrlString CreateBase64UrlString(IEnumerable<byte> base64UrlBytes) | ||
{ | ||
var result = Base64UrlEncoder.Encode(base64UrlBytes.ToArray()); | ||
return new Base64UrlString(result); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/WalletFramework.Core/Credentials/Abstractions/ICredential.cs
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,9 @@ | ||
namespace WalletFramework.Core.Credentials.Abstractions; | ||
|
||
/// <summary> | ||
/// This interface is used to represent a credential. | ||
/// </summary> | ||
public interface ICredential | ||
{ | ||
CredentialId GetId(); | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/WalletFramework.Core/Cryptography/Errors/InvalidSignatureError.cs
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,5 @@ | ||
using WalletFramework.Core.Functional; | ||
|
||
namespace WalletFramework.Core.Cryptography.Errors; | ||
|
||
public record InvalidSignatureError(string Message, Exception E) : Error(Message, E); |
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,21 @@ | ||
using WalletFramework.Core.Base64Url; | ||
|
||
namespace WalletFramework.Core.Cryptography.Models; | ||
|
||
public record PublicKey(Base64UrlString X, Base64UrlString Y) | ||
{ | ||
public string KeyType => "EC"; | ||
|
||
public string Curve => "P-256"; | ||
} | ||
|
||
public static class PublicKeyFun | ||
{ | ||
public static object ToJwkObj(this PublicKey publicKey) => new | ||
{ | ||
kty = publicKey.KeyType, | ||
crv = publicKey.Curve, | ||
x = publicKey.X.ToString(), | ||
y = publicKey.Y.ToString() | ||
}; | ||
} |
53 changes: 53 additions & 0 deletions
53
src/WalletFramework.Core/Cryptography/Models/RawSignature.cs
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,53 @@ | ||
using Org.BouncyCastle.Asn1; | ||
using WalletFramework.Core.Cryptography.Errors; | ||
using WalletFramework.Core.Functional; | ||
|
||
namespace WalletFramework.Core.Cryptography.Models; | ||
|
||
public readonly struct RawSignature | ||
{ | ||
private byte[] Value { get; } | ||
|
||
public byte[] AsByteArray => Value; | ||
|
||
public RawSignature(byte[] value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public static implicit operator byte[](RawSignature signature) => signature.AsByteArray; | ||
|
||
public static Validation<RawSignature> FromDerSignature(byte[] derSignature) | ||
{ | ||
try | ||
{ | ||
var seq = (Asn1Sequence)Asn1Object.FromByteArray(derSignature); | ||
var r = ((DerInteger)seq[0]).Value; | ||
var s = ((DerInteger)seq[1]).Value; | ||
var rBytes = r.ToByteArrayUnsigned(); | ||
var sBytes = s.ToByteArrayUnsigned(); | ||
rBytes = PadTo32Bytes(rBytes); | ||
sBytes = PadTo32Bytes(sBytes); | ||
|
||
var signatureBytes = rBytes.Concat(sBytes).ToArray(); | ||
return new RawSignature(signatureBytes); | ||
} | ||
catch (Exception e) | ||
{ | ||
return new InvalidSignatureError("The signature could not be transformed to RAW format", e); | ||
} | ||
} | ||
|
||
private static byte[] PadTo32Bytes(byte[] value) | ||
{ | ||
if (value.Length == 32) | ||
return value; | ||
|
||
if (value.Length > 32) | ||
throw new ArgumentException("Value is too large to fit in 32 bytes"); | ||
|
||
var padded = new byte[32]; | ||
Array.Copy(value, 0, padded, 32 - value.Length, value.Length); | ||
return padded; | ||
} | ||
} |
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,27 @@ | ||
using System.Security.Cryptography; | ||
|
||
namespace WalletFramework.Core.Encoding; | ||
|
||
public readonly struct Sha256Hash | ||
{ | ||
private byte[] Value { get; } | ||
|
||
private Sha256Hash(byte[] value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public byte[] AsBytes => Value; | ||
|
||
public override string ToString() => Value.ToString(); | ||
|
||
public static implicit operator byte[](Sha256Hash sha256Hash) => sha256Hash.Value; | ||
|
||
public static Sha256Hash ComputeHash(byte[] value) | ||
{ | ||
var sha256 = SHA256.Create(); | ||
var hash = sha256.ComputeHash(value); | ||
return new Sha256Hash(hash); | ||
} | ||
} | ||
|
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
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
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,6 @@ | ||
namespace WalletFramework.Core.String; | ||
|
||
public static class StringFun | ||
{ | ||
public static bool IsNullOrEmpty(this string? value) => string.IsNullOrEmpty(value); | ||
} |
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,12 @@ | ||
namespace WalletFramework.Core.Versioning; | ||
|
||
public static class VersionFun | ||
{ | ||
public static string ToMajorMinorString(this Version version) | ||
{ | ||
var major = version.Major.ToString(); | ||
var minor = version.Minor.ToString(); | ||
|
||
return major + "." + minor; | ||
} | ||
} |
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
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,53 @@ | ||
using PeterO.Cbor; | ||
using WalletFramework.Core.Functional; | ||
|
||
namespace WalletFramework.MdocLib.Cbor; | ||
|
||
/// <summary> | ||
/// A CBOR encoded byte string which can be tagged or untagged | ||
/// </summary> | ||
public readonly struct CborByteString | ||
{ | ||
private CBORObject Value { get; } | ||
|
||
private CborByteString(CBORObject value) => Value = value; | ||
|
||
public CBORObject Decode() => CBORObject.DecodeFromBytes(Value.GetByteString()); | ||
|
||
public CBORObject AsCbor => Value; | ||
|
||
public static implicit operator CBORObject(CborByteString cborByteString) => cborByteString.Value; | ||
|
||
public static Validation<CborByteString> ValidCborByteString(CBORObject cbor) | ||
{ | ||
try | ||
{ | ||
var bs = cbor.GetByteString(); | ||
CBORObject.DecodeFromBytes(bs); | ||
return new CborByteString(cbor); | ||
} | ||
catch (Exception e) | ||
{ | ||
return new InvalidCborByteStringError(cbor.ToString(), e); | ||
} | ||
} | ||
} | ||
|
||
public static class CborByteStringFun | ||
{ | ||
public static CborByteString ToCborByteString(this CBORObject cbor) | ||
{ | ||
var encodedByteString = CBORObject.FromObject(cbor.EncodeToBytes()); | ||
return CborByteString | ||
.ValidCborByteString(encodedByteString) | ||
.UnwrapOrThrow(new InvalidOperationException("CborByteString implementation is corrupt")); | ||
} | ||
|
||
public static CborByteString ToTaggedCborByteString(this CBORObject cbor) | ||
{ | ||
var wrappedByteString = CBORObject.FromObjectAndTag(cbor.EncodeToBytes(), 24); | ||
return CborByteString | ||
.ValidCborByteString(wrappedByteString) | ||
.UnwrapOrThrow(new InvalidOperationException("CborByteString implementation is corrupt")); | ||
} | ||
} |
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
Oops, something went wrong.