From: Nicolas Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: sha256 rsa signing in factotum
Date: Wed, 8 Feb 2017 19:39:36 -0800 [thread overview]
Message-ID: <0d440476-9db5-0815-e218-7e277fb9b378@offblast.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 112 bytes --]
attached is a diff to support sha256 in the pkcs#1 rsa signing in
factotum. if this seems okay, i'll commit it.
[-- Attachment #2: rsa.c.diff --]
[-- Type: text/plain, Size: 1217 bytes --]
diff -r 00c7fa1bc4fc sys/src/cmd/auth/factotum/rsa.c
--- a/sys/src/cmd/auth/factotum/rsa.c Mon Feb 06 04:25:38 2017 +0100
+++ b/sys/src/cmd/auth/factotum/rsa.c Thu Feb 09 03:35:36 2017 +0000
@@ -219,6 +219,8 @@
dlen = SHA1dlen;
else if(strcmp(hash, "md5") == 0)
dlen = MD5dlen;
+ else if(strcmp(hash, "sha256") == 0)
+ dlen = SHA2_256dlen;
else
return failure(fss, "unknown hash function %s", hash);
if(n != dlen)
@@ -299,6 +301,7 @@
*
* SHA1 = 1.3.14.3.2.26
* MDx = 1.2.840.113549.2.x
+ * SHA256 = 2.16.840.1.101.3.4.2.1
*/
#define O0(a,b) ((a)*40+(b))
#define O2(x) \
@@ -309,9 +312,8 @@
(((x)>> 7)&0x7F)|0x80, \
((x)&0x7F)
uchar oidsha1[] = { O0(1, 3), 14, 3, 2, 26 };
-uchar oidmd2[] = { O0(1, 2), O2(840), O3(113549), 2, 2 };
uchar oidmd5[] = { O0(1, 2), O2(840), O3(113549), 2, 5 };
-
+uchar oidsha256[] = { O0(2, 16), O2(840), 1, 101, 3, 4, 2, 1 };
/*
* DigestInfo ::= SEQUENCE {
* digestAlgorithm AlgorithmIdentifier,
@@ -339,6 +341,9 @@
}else if(strcmp(alg, "md5") == 0){
obj = oidmd5;
olen = sizeof(oidmd5);
+ }else if(strcmp(alg, "sha256") == 0){
+ obj = oidsha256;
+ olen = sizeof(oidsha256);
}else{
sysfatal("bad alg in mkasn1");
return -1;
next reply other threads:[~2017-02-09 3:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 3:39 Nicolas Owens [this message]
2017-02-09 8:05 ` [9front] " cinap_lenrek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d440476-9db5-0815-e218-7e277fb9b378@offblast.org \
--to=mischief@offblast.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).