src/AESGCM.php
private static function encryptWithPHP($K, $key_length, $IV, $P = null, $A = null, $tag_length = 128)
    {
        list($J0, $v, $a_len_padding, $H) = self::common($K, $key_length, $IV, $A);

        $C = self::getGCTR($K, $key_length, self::getInc(32, $J0), $P);
        $u = self::calcVector($C);
        $c_len_padding = self::addPadding($C);

        $S = self::getHash($H, $A.str_pad('', $v / 8, "\0").$C.str_pad('', $u / 8, "\0").$a_len_padding.$c_len_padding);
        $T = self::getMSB($tag_length, self::getGCTR($K, $key_length, $J0, $S));

        return [$C, $T];
    }
private static function encryptWithPHP($K, $key_length, $IV, $P = null, $A = null, $tag_length = 128)
    {
        list($J0, $v, $a_len_padding, $H) = self::common($K, $key_length, $IV, $A);

        $C = self::getGCTR($K, $key_length, self::getInc(32, $J0), $P);
        $u = self::calcVector($C);
        $c_len_padding = self::addPadding($C);

        $S = self::getHash($H, $A.str_pad('', $v / 8, "\0").$C.str_pad('', $u / 8, "\0").$a_len_padding.$c_len_padding);
        $T = self::getMSB($tag_length, self::getGCTR($K, $key_length, $J0, $S));

        return [$C, $T];
    }
private static function encryptWithPHP ( $ K , $ key_length , $ IV , $ P = null , $ A = null , $ tag_length = 128 ) { list ( $ J0 , $ v , $ a_len_padding , $ H ) = self :: common ( $ K , $ key_length , $ IV , $ A ) ; $ C = self :: getGCTR ( $ K , $ key_length , self :: getInc ( 32 , $ J0 ) , $ P ) ; $ u = self :: calcVector ( $ C ) ; $ c_len_padding = self :: addPadding ( $ C ) ; $ S = self :: getHash ( $ H , $ A . str_pad ( '' , $ v / 8 , "\0" ) . $ C . str_pad ( '' , $ u / 8 , "\0" ) . $ a_len_padding . $ c_len_padding ) ; $ T = self :: getMSB ( $ tag_length , self :: getGCTR ( $ K , $ key_length , $ J0 , $ S ) ) ; return [ $ C , $ T ] ; }
@param string      $K          Key encryption key
@param string      $key_length Key length
@param string      $IV         Initialization vector
@param null|string $P          Data to encrypt (null for authentication)
@param null|string $A          Additional Authentication Data
@param int         $tag_length Tag length

@return array
@param string $K Key encryption key @param string $key_length Key length @param string $IV Initialization vector @param null|string $P Data to encrypt ( null for authentication ) @param null|string $A Additional Authentication Data @param int $tag_length Tag length