From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 33C991B0000A for ; Tue, 27 Sep 2016 22:05:58 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 1DDC5B5D895 for ; Tue, 27 Sep 2016 22:37:54 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id C5F5018CC8DC for ; Tue, 27 Sep 2016 22:37:54 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7F0301205DA; Tue, 27 Sep 2016 22:37:54 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9F1B51205CB for ; Tue, 27 Sep 2016 22:37:51 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=BLTKv0ulqoglKR3c/Sr0+BONcnY=; b=xaTZtt+R7Wa1HP4A0J eNV4LHL/ifcyGu8gho5/sOGKQ6z5k5lmxmDXq/YgkyOdqHYAa/MboCkj/9VCdiL1 ufybtxBz0Rp4V2x9xLolYGabxGm6rgVEohCfWZSn0Z6Cmwp1SKjK+1tZNcFARvmH DJlJfJPiHMLpT6IY2SKMw/ELI= Received: by filter0416p1mdw1.sendgrid.net with SMTP id filter0416p1mdw1.12799.57EA762A29 2016-09-27 13:37:46.279678977 +0000 UTC Received: from herokuapp.com (ec2-54-204-70-93.compute-1.amazonaws.com [54.204.70.93]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id AOdWfCLhRl6hjUNd53whfw Tue, 27 Sep 2016 13:37:46.245 +0000 (UTC) Date: Tue, 27 Sep 2016 13:37:46 +0000 From: nobu@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 52265 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10098 X-Redmine-Issue-Author: arrtchiu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4a+hpNwK6voNPPMq0Hb2tdiFDgE3xUQCxwVS MWIADhPWx7G6cxLpwA9dv86G8CFxFMXhBOjTW3jf+Era2FZ7o+IHm3jeyfbWJa9Wj9P9AnFeH6IZ+8 Hg5YyyWsWFJKX+F7b6rMHI74b9tbP1b1o+FNEtgemTHjRotx3MDbyEiJMA== X-ML-Name: ruby-core X-Mail-Count: 77429 Subject: [ruby-core:77429] [Ruby trunk Feature#10098] [PATCH] Timing-safe string comparison for OpenSSL::HMAC X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10098 has been updated by Nobuyoshi Nakada. `secure` sounds vague, and `compare` doesn't address the point by shyouhei, I think. ---------------------------------------- Feature #10098: [PATCH] Timing-safe string comparison for OpenSSL::HMAC https://bugs.ruby-lang.org/issues/10098#change-60686 * Author: Matt U * Status: Feedback * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I could be totally wrong, but it seems the standard library doesn't provide a reliable way of comparing hashes in constant-time. * The docs for `OpenSSL::HMAC` encourage the use of `Digest#to_s` (see: http://ruby-doc.org/stdlib-2.1.0/libdoc/openssl/rdoc/OpenSSL/HMAC.html#method-c-new ) * Ruby's string comparison uses memcmp, which isn't timing safe (see: http://rxr.whitequark.org/mri/source/string.c#2382 ) With this patch I propose to add an additional method, `OpenSSL::HMAC#verify`, which takes a binary string with a digest and compares it against the computed hash. ---Files-------------------------------- hmac-timing.patch (2.5 KB) hmac-timing.patch (2.48 KB) tsafe_eql.patch (2.48 KB) tsafe_inline.patch (3.51 KB) 0001-add-timing-safe-string-compare-method.patch (4.31 KB) -- https://bugs.ruby-lang.org/