From patchwork Wed Jul 4 12:46:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wido den Hollander X-Patchwork-Id: 1155931 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 51A4F3FE4F for ; Wed, 4 Jul 2012 12:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751081Ab2GDMqs (ORCPT ); Wed, 4 Jul 2012 08:46:48 -0400 Received: from smtp02.mail.pcextreme.nl ([109.72.87.138]:52463 "EHLO smtp02.mail.pcextreme.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890Ab2GDMqs (ORCPT ); Wed, 4 Jul 2012 08:46:48 -0400 Received: from amd.ceph.widodh.nl (amd.ceph.widodh.nl [31.25.100.162]) by smtp02.mail.pcextreme.nl (Postfix) with ESMTPA id 89ABF4023D; Wed, 4 Jul 2012 14:46:46 +0200 (CEST) From: Wido den Hollander To: ceph-devel@vger.kernel.org Cc: Wido den Hollander Subject: [PATCH] Generate URL-safe base64 strings for keys. Date: Wed, 4 Jul 2012 14:46:27 +0200 Message-Id: <1341405987-26469-1-git-send-email-wido@widodh.nl> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org By using this we prevent scenarios where cephx keys are not accepted in various situations. Replacing the + and / by - and _ we generate URL-safe base64 keys Signed-off-by: Wido den Hollander --- src/common/armor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/armor.c b/src/common/armor.c index d1d5664..7f73da1 100644 --- a/src/common/armor.c +++ b/src/common/armor.c @@ -9,7 +9,7 @@ * base64 encode/decode. */ -const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; static int encode_bits(int c) { @@ -24,9 +24,9 @@ static int decode_bits(char c) return c - 'a' + 26; if (c >= '0' && c <= '9') return c - '0' + 52; - if (c == '+') + if (c == '+' || c == '-') return 62; - if (c == '/') + if (c == '/' || c == '_') return 63; if (c == '=') return 0; /* just non-negative, please */