I’m trying to make a function that appends 2 longs into one and back again.
I used the (ac) + (ad) + (bc) + (bd) formula to combine the numbers.
I have searched for and wide (including this site) with no luck as to how to split the number into two.
I’m using PHP which as you know doesn’t have functions to convert floating point numbers into binary or hex.
I used unpack() with the “J*” setting. Each number returned is 8 bytes long.
I would like to be able to split it in the middle.
If anybody has any advice on how I can achieve this I will be forever thankful.
EDIT: I am trying to concat the two long strings into one (hash/ciphertext/aad) so I can do Polynomial multiplication so I can generate a hash for users with PHP versions less than 7.1.
PHP 7.1 and greater’s openssl_encypt() has support for the tags. The versions less than 7.1 don’t.
It’s been a pain due to PHP’s limitations regarding binary data. All implementations of GCM/CCM require data converted to a 128-bit number and the only number that can be 128-bits is a float number.
The implementations I found are too complex when all I want to do is find a way to get GCM/CCM working with PHP versions less than 7.1.
Additionally, you can’t even use openssl to encrypt GCM data if less than 7.1 because it does not provide a way to validate the tag.
PHP examples do NOT tell you this.
Hope this helps.