9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] [limbo] I tried keyring, but it was the wrong number
@ 2009-07-30 12:54 maht
  2009-07-30 13:46 ` Charles Forsyth
  2009-07-30 13:47 ` Charles Forsyth
  0 siblings, 2 replies; 5+ messages in thread
From: maht @ 2009-07-30 12:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

Hi, sorry for this cross posting, I posted it to inferno yesterday but
I'm not getting through (non of my mail is, must work that out)

I've been trying to sign some data with a generated secret using the
attached Limbo. Afaik the secret is ok, it passed checkSK in keyring.c

I got as far as here with the debugging, I don't know how to work out
which function is being called

/usr/local/inferno-os/libinterp/keyring.c:999
         c->signa = (*sa->vec->sign)(b, sk->key);

running :
% sign_test < secret
[$Keyring] Broken: "mpdiv: divide by zero"
sh: 5 "$Keyring":mpdiv: divide by zero

; stack 5
unknown fn() Module $Keyring PC 1445847206
unknown fn() Module ./sign_test.dis PC 42
externalexec() sh.b:919.2, 30




[-- Attachment #2: secret --]
[-- Type: text/plain, Size: 1019 bytes --]

rsa
maht
l7w4uJyl+UlC6y4cG/tGYaKRcb5ep1igRvlfumxj3aEBDHu1vKZsmMmHzHGCQZl1B9MlAdY+paCoNqP+In1nCcYdn9S9zIBACz9TLXIk9xGCKKhvPw5rlgSwPOEKVcK7O/kvMhZUOPKm+Woefgx9HaenWX2CqzUr56j8kFyZcN1Ax5/zMzzE4d26mHipGOZdWtmjIad8/vYQW9dlOE1U5JCKVQzlyrclzTdYzZ76oVHaDtojjLU8gtOzRxLWmARbU7++QORvgYEOyv+e86fi9iWQlvGsK9FxMci/t+utKlymG4ZE2Cc5+pv0BDp/1Zmd63i8nyyikW/g8EuGBiLyA78l0DcuucOvtSBHc+0tdpZ9/MooNI/p3hMWrBUqPnodwQidQ1cSw+hZaPAMZlE8ipwnhk6SZErRa/+0ZRAfPAvPsxo/hbvfFbK0yG9OqR/4FhVpF+hihn1sSdIdKL11t7lH7x2u0uiSLRn7FH9KuQhflrbfUKeNIAFATzEYyiRZONh4/DG0Hw3PqVTbQXG771p7yDLP4oE5DJmXVZT6JpOWjPUZ/mUeVLCSiuK9EXCAFG0uCjzeWFMnEvPITyiRmp7g2+y4NdO4XgiRr09kmnTkTLXTah9WeF5P7D4HXZsmPiB0S9e+oywmF3DhnWHbgPCK9g+8cYjHziF6HsJ4lsU=
AAAAHQ==
eFd8bxsih+qn1QFCbnfWt12ffYVT5dOH8atL7CD/wW4JqMwLuO3sMo4t6MP0jE2RyGmql4abndexjHBoc6FAEJRMde9YvKxWGpNTn6EmJQ3i0Mw062O2bicHXGvcDw0zZIfV+5YffJ0jUw2K8TYK9DWEubvRkJzt2wpwCJAPw3Gu9plW86vISTREipSpbAYmus/rT6glV3O0ssVQRyLZZdO9KPiS8Dj6q5XTq+gEkZkxWzo/gUBKeWobbVWPtlu7MMQ1yYkI/Md1qdOPuGqrLSaez/125PWOvY2POZea/kl66bEcHjDEDWE0Sflu

[-- Attachment #3: sign_test.b --]
[-- Type: text/plain, Size: 1447 bytes --]

implement Sign;

include "sys.m";
	sys: Sys;
	sprint: import sys;
include "draw.m";
include "keyring.m";
	keyring: Keyring;
	DigestState, PK: import keyring;

Sign: module {
	init:	fn(nil: ref Draw->Context, args: list of string);
};

Metafilesizemax: con 8*1024;

hash := "sha1";

# usage: sign_test [hashname] < secretkey

init(nil: ref Draw->Context, argv: list of string)
{
	sys = load Sys Sys->PATH;
	keyring = load Keyring Keyring->PATH;

	if(len argv > 1)
		hash = hd tl argv;

	(skd, err) := readstdin(Metafilesizemax);
	if(err != nil) {

	} else {
		sk := keyring->strtosk(string skd);
		if(sk == nil) {
			warn("malformed secret key");
		} else {
			bytes := array of byte "some data";
			dstate := keyring->sha1(bytes, len bytes, nil, nil);
			if(dstate == nil) {
				warn("failed to make digest");
			} else {
				exp := 1258801674;  # long time in the future
				cert := keyring->sign(sk, exp, dstate, hash);
				if(cert == nil)
					warn("did not make certificate");
				else
					sys->print("%s", keyring->certtostr(cert));
			}
		}
	}
}

readstdin(maxsize: int): (array of byte, string)
{

	n := sys->readn(sys->fildes(0), d := array[maxsize] of byte, len d);
	if(n < 0)
		return (nil, sprint("read stdin %r"));
	if(n == len d)
		return (nil, sprint("file stdin too large"));
	return (d[:n], nil);
}

warn(s: string)
{
	sys->fprint(sys->fildes(2), "%s\n", s);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] [limbo] I tried keyring, but it was the wrong number
  2009-07-30 12:54 [9fans] [limbo] I tried keyring, but it was the wrong number maht
@ 2009-07-30 13:46 ` Charles Forsyth
  2009-07-30 13:47 ` Charles Forsyth
  1 sibling, 0 replies; 5+ messages in thread
From: Charles Forsyth @ 2009-07-30 13:46 UTC (permalink / raw)
  To: 9fans

if you make an entry in the bugs list at inferno-os.googlecode.com i'll look at it shortly.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] [limbo] I tried keyring, but it was the wrong number
  2009-07-30 12:54 [9fans] [limbo] I tried keyring, but it was the wrong number maht
  2009-07-30 13:46 ` Charles Forsyth
@ 2009-07-30 13:47 ` Charles Forsyth
  2009-07-30 16:35   ` Charles Forsyth
  1 sibling, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2009-07-30 13:47 UTC (permalink / raw)
  To: 9fans

sorry. i accidentally deleted the first line of that reply:
it will be mpdiv via mpmod via mpexp via rsaencrypt,
with a zero modulus (which suggests the key wasn't unpacked correctly).
but if you make an entry in the bugs list ... etc



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] [limbo] I tried keyring, but it was the wrong number
  2009-07-30 13:47 ` Charles Forsyth
@ 2009-07-30 16:35   ` Charles Forsyth
  2009-08-11 14:55     ` matt
  0 siblings, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2009-07-30 16:35 UTC (permalink / raw)
  To: 9fans

>with a zero modulus (which suggests the key wasn't unpacked correctly).

my deliberate mistake (it won't be using rsaencrypt but rsadecrypt)
happened to highlight the actual problem, which is that strtosk
shouldn't accept a string that looks to me (if not to it)
like a public key not a private/secret one,
producing something with plenty of zero mpint potential divisors.
b00f!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] [limbo] I tried keyring, but it was the wrong number
  2009-07-30 16:35   ` Charles Forsyth
@ 2009-08-11 14:55     ` matt
  0 siblings, 0 replies; 5+ messages in thread
From: matt @ 2009-08-11 14:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Charles Forsyth wrote:

>>with a zero modulus (which suggests the key wasn't unpacked correctly).
>>
>>
>
>my deliberate mistake (it won't be using rsaencrypt but rsadecrypt)
>happened to highlight the actual problem, which is that strtosk
>shouldn't accept a string that looks to me (if not to it)
>like a public key not a private/secret one,
>producing something with plenty of zero mpint potential divisors.
>b00f!
>
>
>
Yes, that was exactly it. I've changed the key generator to use default
names. How I mixed them up I don't know, but I did.






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-08-11 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-30 12:54 [9fans] [limbo] I tried keyring, but it was the wrong number maht
2009-07-30 13:46 ` Charles Forsyth
2009-07-30 13:47 ` Charles Forsyth
2009-07-30 16:35   ` Charles Forsyth
2009-08-11 14:55     ` matt

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).