-
Notifications
You must be signed in to change notification settings - Fork 53
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 #833 from walt-id/Azure-kms-inetgration
WAL-697 : Added Azure kms integration
- Loading branch information
Showing
21 changed files
with
853 additions
and
51 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
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
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
39 changes: 39 additions & 0 deletions
39
waltid-libraries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/KeyUtils.kt
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,39 @@ | ||
package id.walt.crypto.keys | ||
|
||
import id.walt.crypto.utils.Base64Utils.encodeToBase64Url | ||
import id.walt.crypto.utils.JsonUtils.toJsonElement | ||
import id.walt.crypto.utils.jwsSigningAlgorithm | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.json.JsonElement | ||
|
||
object KeyUtils { | ||
|
||
|
||
fun rawSignaturePayloadForJws( | ||
plaintext: ByteArray, | ||
headers: Map<String, JsonElement>, | ||
keyType: KeyType, | ||
): Triple<String, String, ByteArray> { | ||
val appendedHeader = HashMap(headers).apply { | ||
put("alg", jwsSigningAlgorithm(keyType).toJsonElement()) | ||
} | ||
|
||
val header = Json.encodeToString(appendedHeader).encodeToByteArray().encodeToBase64Url() | ||
val payload = plaintext.encodeToBase64Url() | ||
|
||
return Triple(header, payload, "$header.$payload".encodeToByteArray()) | ||
} | ||
|
||
fun signJwsWithRawSignature( | ||
rawSignature: ByteArray, | ||
header: String, | ||
payload: String | ||
): String { | ||
val encodedSignature = rawSignature.encodeToBase64Url() | ||
val jws = "$header.$payload.$encodedSignature" | ||
|
||
return jws | ||
} | ||
|
||
} |
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
16 changes: 16 additions & 0 deletions
16
...braries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/azure/AzureAuth.kt
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,16 @@ | ||
package id.walt.crypto.keys.azure | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlin.js.ExperimentalJsExport | ||
import kotlin.js.JsExport | ||
|
||
|
||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
@Serializable | ||
data class AzureAuth( | ||
val clientId: String, | ||
val clientSecret: String, | ||
val tenantId: String, | ||
val keyVaultUrl: String, | ||
) |
Oops, something went wrong.