From 1763d7b9adcc6df7dce5c6a558f084eb36a02c00 Mon Sep 17 00:00:00 2001 From: Himaja Dhanyamraju <43470317+HimajaDhanyamraju2@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:50:30 +0530 Subject: [PATCH] MOSIP-24522 (#235) Signed-off-by: HimajaDhanyamraju2 --- hub/hub_service.bal | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hub/hub_service.bal b/hub/hub_service.bal index d065715..4d28434 100644 --- a/hub/hub_service.bal +++ b/hub/hub_service.bal @@ -174,9 +174,10 @@ service object { if config:SECURITY_ON { check security:authorizeSubscriber(headers, message.hubTopic); } - byte[] hash = crypto:hashSha256(( message.hubSecret).toBytes()); - message.hubSecret = hash.toBase64(); + string hubSecret = message.hubSecret; + message.hubSecret = (crypto:hashSha256(hubSecret.toBytes())).toBase64(); log:printInfo("Subscription request received", payload = message); + message.hubSecret = hubSecret; return websubhub:SUBSCRIPTION_ACCEPTED; } @@ -201,9 +202,10 @@ service object { log:printError("Subscriber has already registered with the Hub", topic = topicName, callback = message.hubCallback); return error websubhub:SubscriptionDeniedError("Subscriber has already registered with the Hub"); } else { - byte[] hash = crypto:hashSha256(( message.hubSecret).toBytes()); - message.hubSecret = hash.toBase64(); + string hubSecret = message.hubSecret; + message.hubSecret = (crypto:hashSha256(hubSecret.toBytes())).toBase64(); log:printInfo("Validation done before sending intent verification", payload = message); + message.hubSecret = hubSecret; } } @@ -227,7 +229,9 @@ service object { } log:printInfo("Random generated iv value", iv = initialVector); byte[] cipherText = check crypto:encryptAesGcm(hubSecret.toBytes(), encryptionKey.toBytes(), initialVector); + log:printInfo("Encrypted cipher text value", cipher = cipherText); cipherText.push(...initialVector); + log:printInfo("Encrypted cipher after appending iv", cipher = cipherText); message.hubSecret = cipherText.toBase64(); }