getNonce example

$this->nonce = str_pad($this->nonce, 12, "\0", STR_PAD_RIGHT);
        }
        return $this->nonce;
    }

    /** * @return string */
    public function getCombinedNonce()
    {
        return $this->getCounter() .
            ParagonIE_Sodium_Core_Util::substr($this->getNonce(), 0, 8);
    }

    /** * @return self */
    public function incrementCounter()
    {
        ++$this->counter;
        return $this;
    }

    
$this->nonce = str_pad($this->nonce, 12, "\0", STR_PAD_RIGHT);
        }
        return $this->nonce;
    }

    /** * @return string */
    public function getCombinedNonce()
    {
        return $this->getCounter() .
            ParagonIE_Sodium_Core32_Util::substr($this->getNonce(), 0, 8);
    }

    /** * @return self */
    public function incrementCounter()
    {
        ++$this->counter;
        return $this;
    }

    
        # crypto_secretstream_xchacha20poly1305_INONCEBYTES];         # size_t i;         # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {         # new_key_and_inonce[i] = state->k[i];         # }         $new_key_and_inonce = $st->getKey();

        # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {         # new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i] =         # STATE_INONCE(state)[i];         # }         $new_key_and_inonce .= ParagonIE_Sodium_Core_Util::substR($st->getNonce(), 0, 8);

        # crypto_stream_chacha20_ietf_xor(new_key_and_inonce, new_key_and_inonce,         # sizeof new_key_and_inonce,         # state->nonce, state->k);
        $st->rekey(ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
            $new_key_and_inonce,
            $st->getCombinedNonce(),
            $st->getKey(),
            ParagonIE_Sodium_Core_Util::store64_le(0)
        ));

        
        # crypto_secretstream_xchacha20poly1305_INONCEBYTES];         # size_t i;         # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {         # new_key_and_inonce[i] = state->k[i];         # }         $new_key_and_inonce = $st->getKey();

        # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {         # new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i] =         # STATE_INONCE(state)[i];         # }         $new_key_and_inonce .= ParagonIE_Sodium_Core32_Util::substR($st->getNonce(), 0, 8);

        # crypto_stream_chacha20_ietf_xor(new_key_and_inonce, new_key_and_inonce,         # sizeof new_key_and_inonce,         # state->nonce, state->k);
        $st->rekey(ParagonIE_Sodium_Core32_ChaCha20::ietfStreamXorIc(
            $new_key_and_inonce,
            $st->getCombinedNonce(),
            $st->getKey(),
            ParagonIE_Sodium_Core32_Util::store64_le(0)
        ));

        
Home | Imprint | This part of the site doesn't use cookies.