From: Andy Polyakov <appro@fy.chalmers.se>
To: openssl-dev@openssl.org
Cc: linuxppc-embedded@ozlabs.org
Subject: Re: PPC bn_div_words routine rewrite
Date: Fri, 01 Jul 2005 19:36:48 +0200 [thread overview]
Message-ID: <42C57F30.902@fy.chalmers.se> (raw)
In-Reply-To: <4dd15d1805063015226379a52c@mail.gmail.com>
> The reason I had to redo this routine, in case anyone is wondering, is
> because ssh-keygen segfaults when this assembly routine returns junk
> to the BN_div_word function. On a ppc, if you issue the command
>
> ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""
>
> The program craps out when it tries to write the public key in ascii decimal.
If would help if you provide evidence such as debugger stack trace and
program output. Provided description makes no sense. "seg-faults when
routine returns junk to BN_div_word"? Seg-fault [segmentation violation]
can occur when you write something to memory and nothing gets written to
memory upon result return. BN_div_word does write to memory, but I fail
to see how a bogus value could possibly trigger seg-fault. The only
possibility is that assembler doesn't follow ABI convention and corrupts
registers, which caller is using/expects to be preserved by callee.
There're several PPC ABI flavors in use, but OpenSSL routines were
designed ABI-neutral, Well, "neutrality" really means "common
denominator for ABI specs examined at the moment of coding," so there is
a window of opportunity that it won't be "neutral" to future ABI, but is
it really case? That your system uses some newly designed PPC ABI? You
never mentioned what's your system...
But you're apparently right about a bug being present in PPC assembler.
I too have got insane [with very few significant digits] decimal
printout of public key generated by ssh-keygen...
>>This is a rewrite of the bn_div_words routine for the PowerPC arch,
>>tested on a MPC8xx processor.
Well, suggested routine apparently sends ssh-keygen on the PPC-based
32-bit system I have access to to an end-less loop... And (cd test; make
test_bn) fails early in BN_sqr... And test/exptest fails miserably with
"bad reciprocal"...
>>I initially thought there is maybe a small mistake in the code that
>>requires a one-liner change
But apparently this appears to be the case! Please verify following:
--- crypto/bn/asm/ppc.pl.orig 2004-04-28 00:05:50.000000000 +0200
+++ crypto/bn/asm/ppc.pl 2005-07-01 18:58:21.105656512 +0200
@@ -1717,7 +1717,7 @@
li r9,1 # r9=1
$SHL r10,r9,r8 # r9<<=r8
$UCMP 0,r3,r10 #
- bc BO_IF,CR0_GT,Lppcasm_div2 #or if (h > (1<<r8))
+ bc BO_IF_NOT,CR0_GT,Lppcasm_div2 #or if (h > (1<<r8))
$UDIV r3,r3,r0 #if not assert(0) divide by 0!
#that's how we signal overflow
bclr BO_ALWAYS,CR0_LT #return. NEVER REACHED.
A.
next prev parent reply other threads:[~2005-07-01 18:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4dd15d1805063003587276af7e@mail.gmail.com>
2005-06-30 22:22 ` PPC bn_div_words routine rewrite David Ho
2005-07-01 17:36 ` Andy Polyakov [this message]
2005-07-04 14:35 ` David Ho
2005-07-05 15:00 ` Andy Polyakov
[not found] <19EE6EC66973A5408FBE4CB7772F6F0A02C8770E@ltnmail.xyplex.com>
[not found] ` <4dd15d1805070508312427a0ba@mail.gmail.com>
2005-07-05 15:45 ` Fwd: " David Ho
2005-07-05 16:36 ` David Ho
2005-07-05 17:01 ` David Ho
2005-07-05 20:21 ` David Ho
2005-07-05 21:22 ` Andy Polyakov
2005-07-05 21:25 ` David Ho
2005-07-05 21:49 ` Andy Polyakov
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=42C57F30.902@fy.chalmers.se \
--to=appro@fy.chalmers.se \
--cc=linuxppc-embedded@ozlabs.org \
--cc=openssl-dev@openssl.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).