r-lib / sodium

R bindings to libsodium

Home Page:https://docs.ropensci.org/sodium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wouldn't data_tag() be more appropriate for authenticating _encrypted_ messages?

dan-reznik opened this issue · comments

hi jeroen, on sodium's vignette you talk about how data tagging can be used to authenticate a key,message pair, e.g.:

key <- hash(charToRaw("This is a secret passphrase"))
msg <- serialize(iris, NULL)
mytag <- data_tag(msg, key)

however, since data is often times transmitted/stored in encrypted format, i would think this function's more typical use would be to tag (msg_cipher,key) or even (msg_cipher,key_cipher) pair, e.g.:

key <- hash(charToRaw("This is a secret passphrase"))
msg <- serialize(iris, NULL)
nonce <- random(24)
msg_cipher <- data_encrypt(msg, key, nonce)
mytag <- data_tag(msg_cipher, key) # or even my_tag <- data_tag(msg_cipher, key_cipher)

am i missing something?