Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dev/compose.openid4vc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:

connector:
image: ghcr.io/nmshd/connector:7.3.0-openid4vc.1@sha256:4be31417d10d67454d7732949601a2136417fefc78107e3751eccea7946a7aca
ports:
- "8080:80"
environment:
CUSTOM_CONFIG_LOCATION: "/config.json"
transportLibrary__baseUrl: "http://consumer-api:8080"
Expand Down
5 changes: 5 additions & 0 deletions .dev/service-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@
},
"cors": {
"origin": "*"
},
"eudiplo": {
"baseUrl": "http://127.0.0.1:3000",
"user": "test-admin",
"password": "57c9cd444bf402b2cc1f5a0d2dafd3955bd9042c0372db17a4ede2d5fbda88e5"
}
}
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class EnmshedHolderKeyManagmentService implements Kms.KeyManagementServic
if (operation.operation === "deleteKey") {
return true;
}
if (operation.operation === "encrypt") {
if (operation.operation === "encrypt" && ["A128GCM", "A256GCM"].includes(operation.encryption.algorithm)) {
return true;
}
return false;
Expand Down Expand Up @@ -342,7 +342,7 @@ export class EnmshedHolderKeyManagmentService implements Kms.KeyManagementServic

public async encrypt(agentContext: AgentContext, options: Kms.KmsEncryptOptions): Promise<Kms.KmsEncryptReturn> {
try {
// encryption via A-256-GCM
// encryption via A-128-GCM/A-256-GCM
// we will call the services side bob and the incoming side alice
if (options.key.keyAgreement === undefined) {
throw new Error("Key agreement is undefined");
Expand All @@ -351,11 +351,14 @@ export class EnmshedHolderKeyManagmentService implements Kms.KeyManagementServic
throw new Error("Key agreement keyId is undefined");
}

const algorithm = options.encryption.algorithm;
const keyLength = options.encryption.algorithm === "A128GCM" ? 128 : 256;

// 1. derive the shared secret via ECDH-ES
const sharedSecret = await this.ecdhEs(options.key.keyAgreement.keyId, options.key.keyAgreement.externalPublicJwk);
agentContext.config.logger.debug(`EKM: Derived shared secret for encryption using ECDH-ES`);
// 2. Concat KDF to form the final key
const derivedKey = this.concatKdf(sharedSecret, 256, "A256GCM", options.key.keyAgreement);
const derivedKey = this.concatKdf(sharedSecret, keyLength, algorithm, options.key.keyAgreement);
// 3. Encrypt the data via AES-256-GCM using libsodium

// create nonce
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export class ShareAuthorizationRequestRequestItemProcessor extends GenericReques
const attribute = (await this.consumptionController.attributes.getLocalAttribute(parsedParams.attributeId)) as OwnIdentityAttribute | undefined;
if (!attribute) throw TransportCoreErrors.general.recordNotFound(LocalAttribute, parsedParams.attributeId.toString());

await this.consumptionController.openId4Vc.acceptAuthorizationRequest(resolvedAuthorizationRequest.authorizationRequest, attribute);
const acceptResult = await this.consumptionController.openId4Vc.acceptAuthorizationRequest(resolvedAuthorizationRequest.authorizationRequest, attribute);
if (acceptResult.status !== 200) {
throw ConsumptionCoreErrors.requests.invalidAcceptParameters("The presentation was not successful. Try again later or select a different credential.");
}

return AcceptResponseItem.from({ result: ResponseItemResult.Accepted });
}
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"@js-soft/docdb-access-loki": "1.4.0",
"@js-soft/docdb-access-mongo": "1.4.0",
"@js-soft/node-logger": "1.2.1",
"@nmshd/connector-sdk": "^7.3.0",
"@types/elliptic": "^6.4.18",
"@types/json-stringify-safe": "^5.0.3",
"@types/lodash": "^4.17.23",
Expand Down
Loading
Loading