Re: [9fans] [limbo] I tried keyring, but it was the wrong number

2009-08-11 Thread matt

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.






[9fans] [limbo] I tried keyring, but it was the wrong number

2009-07-30 Thread maht
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



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=
HQ==
eFd8bxsih+qn1QFCbnfWt12ffYVT5dOH8atL7CD/wW4JqMwLuO3sMo4t6MP0jE2RyGmql4abndexjHBoc6FAEJRMde9YvKxWGpNTn6EmJQ3i0Mw062O2bicHXGvcDw0zZIfV+5YffJ0jUw2K8TYK9DWEubvRkJzt2wpwCJAPw3Gu9plW86vISTREipSpbAYmus/rT6glV3O0ssVQRyLZZdO9KPiS8Dj6q5XTq+gEkZkxWzo/gUBKeWobbVWPtlu7MMQ1yYkI/Md1qdOPuGqrLSaez/125PWOvY2POZea/kl66bEcHjDEDWE0Sfluimplement 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);
}



Re: [9fans] [limbo] I tried keyring, but it was the wrong number

2009-07-30 Thread Charles Forsyth
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!