Skip to content
Merged
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
7 changes: 7 additions & 0 deletions sdk/src/main/java/com/uid2/utils/KeyUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ internal interface KeyUtils {
}

override fun generateServerPublicKey(publicKey: String): PublicKey? {
// Check to make sure the given public key is longer than the expected prefix.
if (publicKey.length <= SERVER_PUBLIC_KEY_PREFIX_LENGTH) {
return null
}

// Attempt to decode the given public key. If the key is malformed, or not in the expected Base64 format,
// null we be returned.
val serverPublicKeyBytes =
publicKey.substring(SERVER_PUBLIC_KEY_PREFIX_LENGTH).decodeBase64() ?: return null

Expand Down