Doc #80236 [Com]: How $tag works in openssl_encrypt() with GCM mode is unclear

[email protected] ("viekkumar249 at gmail dot com") Thu, 13 Apr 2023 09:48:09 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=80236&edit=1

 ID:                 80236
 Comment by:         viekkumar249 at gmail dot com
 Reported by:        adrian at proresult dot no
 Summary:            How $tag works in openssl_encrypt() with GCM mode is
                     unclear
 Status:             Open
 Type:               Documentation Problem
 Package:            OpenSSL related
 Operating System:   Any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Automobile Rider are sharing latest news about auto, electric vehicle and bike, scooter, cars etc. More info to visit:(https://automobilerider.com)github.com


Previous Comments:
------------------------------------------------------------------------
[2020-10-15 03:24:03] a at b dot c dot de

I agree that it could be clearer that those two variables are for values returned by the function. There is an example of their use further down, but as it is only a snippet one could easily think that maybe those variables were being set in earlier code not shown.

I've made a submission through the online editor edit.php.net that I think gives the right idea. I didn't go to too much detail about what the tag is or what it's for or how it's to be used because - this being crypto and therefore Not A Toy™ - specialised references would be a more appropriate source for the necessary background.

------------------------------------------------------------------------
[2020-10-14 16:24:23] adrian at proresult dot no

Description:
------------
---
From manual page: https://php.net/function.openssl-encrypt
---
As the documentation stands today, I think it's unclear how $tag is set and how you're supposed to retrieve/use it. After searching through other online sources for a while, I figured out that $tag is automatically set when calling openssl_encrypt(). Once I know, it seems obvious (since it's passed by reference, the function can alter its value), but before I was spoon-fed this information elsewhere, I had a hard time understanding how $tag should be formed, how it is set, and how it can be retrieved by the programmer. I suggest making this clearer in the documentation to avoid future confusion for other developers new to the openssl_* functions.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80236&edit=1