INNER CODE UNIT · C

ciphertext_len

jedisct1/libsodium-php · libsodium.c:2082

    ciphertext_len = msg_len + crypto_aead_aes256gcm_ABYTES;
    ciphertext = zend_string_checked_alloc((size_t) ciphertext_len, 0);
    if (crypto_aead_aes256gcm_encrypt
        ((unsigned char *) ZSTR_VAL(ciphertext), &ciphertext_real_len, msg,
         (unsigned long long) msg_len,
         ad, (unsigned long long) ad_len, NULL, npub, secretkey) != 0) {
        zend_string_free(ciphertext);
        zend_throw_exception(sodium_exception_ce, "internal error", 0);
        return;
    }
    if (ciphertext_real_len <= 0U || ciphertext_real_len >= SIZE_MAX ||
        ciphertext_real_len > ciphertext_len) {
        zend_string_free(ciphertext);
        zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
        return;
    }
    PHP_SODIUM_ZSTR_TRUNCATE(ciphertext, (size_t) ciphertext_real_len);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…