From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B2AB923BAA for ; Tue, 15 May 2018 07:04:34 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FqbAQfsA_36Z for ; Tue, 15 May 2018 07:04:34 -0400 (EDT) Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.181.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 6C3DF23A7D for ; Tue, 15 May 2018 07:04:34 -0400 (EDT) From: Alexander Turenko Subject: [tarantool-patches] [PATCH] Add test case for fiber safety of digest.pbkdf2 Date: Tue, 15 May 2018 14:04:21 +0300 Message-Id: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Ilya Markov , Kirill Yukhin Cc: Alexander Turenko , tarantool-patches@freelists.org Follows up #3396. --- branch: Totktonada/gh-3396-fiber-safe-pbkdf2-test travis-ci: https://travis-ci.org/tarantool/tarantool/builds/379156714 test/app/digest.result | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ test/app/digest.test.lua | 19 +++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/test/app/digest.result b/test/app/digest.result index bf1815136..d41efde3f 100644 --- a/test/app/digest.result +++ b/test/app/digest.result @@ -5,6 +5,9 @@ test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua:\"]: '") --- - true ... +fiber = require('fiber') +--- +... digest = require('digest') --- ... @@ -576,3 +579,60 @@ test_run:cmd("clear filter") --- - true ... +-- gh-3396: fiber-safe pbkdf2 +res = {} +--- +... +sentry = fiber.channel() +--- +... +_ = test_run:cmd("setopt delimiter ';'") +--- +... +function test_pbkdf2() + local digest = require('digest') + for i = 1, 10 do + table.insert(res, digest.pbkdf2('', 'salt', 100, 32):hex()) + end + sentry:put(fiber.id()) +end; +--- +... +_ = test_run:cmd("setopt delimiter ''"); +--- +... +_ = fiber.create(test_pbkdf2) +--- +... +_ = fiber.create(test_pbkdf2) +--- +... +_ = sentry:get() +--- +... +_ = sentry:get() +--- +... +res +--- +- - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 + - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9 +... diff --git a/test/app/digest.test.lua b/test/app/digest.test.lua index 3134efc92..7ecda91bc 100644 --- a/test/app/digest.test.lua +++ b/test/app/digest.test.lua @@ -1,6 +1,7 @@ test_run = require('test_run').new() test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua:\"]: '") +fiber = require('fiber') digest = require('digest') type(digest) @@ -184,3 +185,21 @@ s err:match("number") digest = nil test_run:cmd("clear filter") + +-- gh-3396: fiber-safe pbkdf2 +res = {} +sentry = fiber.channel() +_ = test_run:cmd("setopt delimiter ';'") +function test_pbkdf2() + local digest = require('digest') + for i = 1, 10 do + table.insert(res, digest.pbkdf2('', 'salt', 100, 32):hex()) + end + sentry:put(fiber.id()) +end; +_ = test_run:cmd("setopt delimiter ''"); +_ = fiber.create(test_pbkdf2) +_ = fiber.create(test_pbkdf2) +_ = sentry:get() +_ = sentry:get() +res -- 2.15.1