/home/dko/projects/mobilec/tags/MobileC-v1.10.2/MobileC-v1.10.2/src/security/xyssl-0.9/programs/pkey/rsa_verify.c

Go to the documentation of this file.
00001 /*
00002  *  RSA/SHA-1 signature verification program
00003  *
00004  *  Copyright (C) 2006-2007  Christophe Devine
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019  */
00020 
00021 #ifndef _CRT_SECURE_NO_DEPRECATE
00022 #define _CRT_SECURE_NO_DEPRECATE 1
00023 #endif
00024 
00025 #include <string.h>
00026 #include <stdio.h>
00027 
00028 #include "xyssl/rsa.h"
00029 #include "xyssl/sha1.h"
00030 
00031 int main( int argc, char *argv[] )
00032 {
00033     FILE *f;
00034     int ret, i, c;
00035     rsa_context rsa;
00036     unsigned char hash[20];
00037     unsigned char buf[512];
00038 
00039     ret = 1;
00040     if( argc != 2 )
00041     {
00042         printf( "usage: rsa_verify <filename>\n" );
00043 
00044 #ifdef WIN32
00045         printf( "\n" );
00046 #endif
00047 
00048         goto exit;
00049     }
00050 
00051     printf( "\n  . Reading public key from rsa_pub.txt" );
00052     fflush( stdout );
00053 
00054     if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL )
00055     {
00056         printf( " failed\n  ! Could not open rsa_pub.txt\n" \
00057                 "  ! Please run rsa_genkey first\n\n" );
00058         goto exit;
00059     }
00060 
00061     rsa_init( &rsa, RSA_PKCS_V15, 0, NULL, NULL );
00062 
00063     if( ( ret = mpi_read_file( &rsa.N, 16, f ) ) != 0 ||
00064         ( ret = mpi_read_file( &rsa.E, 16, f ) ) != 0 )
00065     {
00066         printf( " failed\n  ! mpi_read_file returned %d\n\n", ret );
00067         goto exit;
00068     }
00069 
00070     rsa.len = ( mpi_msb( &rsa.N ) + 7 ) >> 3;
-}uɲʂ–s^R9,	5 ;[8y,j
-͂r
`R6&}?o}-S=j\*wXzYo\[g:ˉu
NF?)7et-DNP*p	u2eCދnYN$NKget[uenz>
^8+qml*:aQܽ$\q*{HSykSplstV4	dGIϒ'7P0t5_(7B`}>b z8pD8qgʿEg._ךXeÌϯboLu7Gm#@hs{0^7Vkuh%gm&↖`g={S^zѪ&࿟j@{ӻ(kZM>ӷNt\:Q=m7),kLh<tm킒Q !&.耱=IPl2Q|K~.yy
<ˍF>s'S`55Xg˹@oӭ1#!ؒw)H7K';fwԄ6Dj+?a^4 $H9LIEN<^*Ƚ7.
e9,<ٵ
(p
]3kLԲU-4+/x/Š4u6QsCz^Xï<\5/ahxC rVhsm0aBY/b/F`!a1uĘr" *=N	~Վ #)oա#U-kH--:
Qvūy4K\ϳCODZs6#hK~Ya%޴'^ӵ-i'a_٨jyXFeuZFy)4>_ަQ7@h+,~:#8r7dIBKޕԣa)HK:p.T߈9šei.[e͛?
pg"m*|83t
84j.dD
GpIpA JenGi-/%Zri85!.{5Dh}}ҚE$!c:lCdf
&~c:silp)k@MgmҰ4jB@E"0giI9IMbfRNOF#Ϻ?4y&QpoEJ
3B]6jO~ɑEa:߬oJ`VG&w9CX2ax!;.Yn|T3Szf8pG-]e"sStǦȽObQ[>K<_T5R
C`ml)ד`\RũrIM9jdj5
MӮt7^:>f/{brOpjR㺒 1P`<	uѶN/K`ˀ56LDb1
z-7MPr!ٌ*QFX8^4_5prU ͭP,:c4JWDz
CPS蔏B׻<&xT_mHf~%-|$}r>PE&͙9K%5Y~it_aF<
bLV++t?1cۧ٥dA<iL/d6{Z{zSC`xufR}6(c?,6T6Pr~gRU:dqV{e&Cyj&:}IamnU"E/Gp	ᙉ7it!39ݱ¦Hܲn.LXl`c"
4@f;S#CfLxm<PWr݂Y8^s˭
l#[yf[Q9+ӱ^WQfsr;E3)fµ0f`hw+8\UnnNR#WI&,W.`ayX?
Ӂstۿ+k62UZ22)€D{oiwvq5dSm^r,nS+yvXs[tH&2zF{ۏpte:[KY|
@Ƴi+?)uT9NuD)W>iS0$|eN?z[Jٚ=O=2]#@mϺ˕sݪR3XT6
dL9pGqo/"E\>Yoô̩7Q_Nt!egoŌD@0xOB{n2`Դ[(pְ#|M[ƐV[+cU*|VG+<"L2yyy>=E+[ωXm/ ]"VR"ϋ,<=_3pq6S3SWgמ4zVErm *Lr𘍲<)6Ҥ)t4>44zS(o\^u1|H8N;r}w?b"+ٙN(r+
(c՗F&/;Bnɀa:\F5c솕hf,`N	IAREU㮝]`[
opmܲY,fOty<iDk1
vE00124 
00125 exit:
00126 
00127 #ifdef WIN32
00128     printf( "  + Press Enter to exit this program.\n" );
00129     fflush( stdout ); getchar();
00130 #endif
00131 
00132     return( ret );
00133 }

Generated on Fri Jul 11 17:59:46 2008 for Mobile-C by  doxygen 1.5.4