Skip to content

AES/GCM usage example #36

@morki

Description

@morki

Hi @whyoleg,

thank you very much for this awesome library. I am using snapshot version to convert my webpush library to multiplatform.

I transformed code from Java Security APIs without issues (using your new ECDH support), but one think I can't find a way to do is this last function:

internal fun encryptAesGcmNoPadding(key: ByteArray, nonce: ByteArray, payload: ByteArray): ByteArray {
   //return CryptographyProvider.Default
   //    .get(AES.GCM)
   //    .keyDecoder()
   //    .decodeFromBlocking(AES.Key.Format.RAW, key)
   //    .cipher()
   //    .encryptBlocking(nonce, payload)

   return Cipher.getInstance("AES/GCM/NoPadding").run {
       init(Cipher.ENCRYPT_MODE, SecretKeySpec(key, "AES"), GCMParameterSpec(128, nonce))
       doFinal(payload)
   }
}

Can you please help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions