Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
key length error fix
  • Loading branch information
mrFlick72 committed Nov 1, 2024
1 parent f7117c9 commit b0d617f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.vauthenticator.server.keys.adapter.local

import com.vauthenticator.server.extentions.toSha256
import com.vauthenticator.server.keys.domain.MasterKid
val toSha256 = "secret".toSha256()
val toSha256 = "CrZKwm8YWGN5xYeKlaC9vXUBAFFzKYsqfaOFSrrqQgA="

class BouncyCastleKeyGeneratorMasterKeyRepository {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class KeyCryptographicOperations(
}

fun encryptKeyWith(masterKid: MasterKid, encodedPlainText: ByteArray): ByteArray {
val masterKey = repository.maskerKeyFor(masterKid);
val key = SecretKeySpec(masterKey.toByteArray(), "AES")
val masterKey = decoder.decode(repository.maskerKeyFor(masterKid));
val key = SecretKeySpec(masterKey, "AES")
val cipher = Cipher.getInstance("AES")
cipher.init(Cipher.ENCRYPT_MODE, key)
return cipher.doFinal(decoder.decode(encodedPlainText))
}

fun decryptKeyWith(masterKid: MasterKid, encodedEncryptedText: ByteArray): ByteArray {
val masterKey = repository.maskerKeyFor(masterKid);
val key = SecretKeySpec(masterKey.toByteArray(), "AES")
val masterKey = decoder.decode(repository.maskerKeyFor(masterKid));
val key = SecretKeySpec(masterKey, "AES")
val cipher = Cipher.getInstance("AES")
cipher.init(Cipher.DECRYPT_MODE, key)
return cipher.doFinal(decoder.decode(encodedEncryptedText))
Expand Down

0 comments on commit b0d617f

Please sign in to comment.