InfoQ

交流

讨论:救命啊php怎样调用Vsign.c

作者 zgz931142 发布于 0000-00-00 分类:php基础编程

下面是Vsign.c文件,放在Apache服务器CGI-BIN目录中,请各位帮帮忙,怎样用PHP调用它。
Vsign.c文件如下:
/*
** vsign.c
**
** Sample for testing library veriicbc.
*/

#include

main( int argc, char *argv[] ) {

int inLen;
unsigned char inData[102400];
int signatureLen;
unsigned char signature[256+1];
int certificateLen;
char certificateFile[100];
/* certificateData must large enough to save all the certificate content */

FILE *infp, *certfp, *sigfp;

if( argc != 3 ) {
printf( "Usage: vsign source-file signature-file " );
printf( "This program does not modify any file. " );
exit( 1 );
}

/* Open the certificate file
if( (certfp=fopen(argv[1],"rb")) == NULL ) {
printf( "Open %s failed ", argv[1] );
exit( 1 );
}

Read certificate content
if( (certificateLen=fread( certificateData, 1, sizeof(certificateData), certfp )) < 0 ) {
printf( "Read %s failed ", argv[1] );
exit( 1 );
}

fclose( certfp );
*/
/* Open the file from which the signature generated */
if( (infp=fopen(argv[1],"rb")) == NULL ) {
printf( "Open %s failed ", argv[2] );
exit( 1 );
}

/* Read the content */
if( (inLen=fread( inData, 1, sizeof(inData), infp )) < 0 ) {
printf( "Read %s failed ", argv[2] );
exit( 1 );
}

fclose( infp );

/* Open the signature */
if( (sigfp=fopen(argv[2],"rb")) == NULL ) {
printf( "Open %s failed ", argv[3] );
exit( 1 );
}

if( (signatureLen=fread( signature, 1, 256, sigfp )) != 256 ) {
printf( "Read %s failed ", argv[3] );
exit( 1 );
}

/* Verify the signature */

memset(certificateFile,0x00,100);
sprintf(certificateFile,"%s","/usr/cz/infosec/unixlib/test/sproxy.crt");
printf("signature is%s ",signature);
if( VerifySignature(
inData,
inLen,
signature,
signatureLen,
certificateFile) != 1 ) {
printf( "Verify signature failed " );
exit( 1 );
}

printf( "OK " );
return 0;
}



逛论坛交流救命啊php怎样调用Vsign.c

加入书签
digg+,
reddit+,
del.icio.us+,
dzone+

0 条回复

回复




  1. 我有话要讲:(可以匿名发表, 发广告的有多远请滚多远!!!)

    昵称: 请输入验证码:


抢着回答

发个php手册,相当不错了,嘿嘿

http://cn2.php.net/get/php_manual_chm_12.zip/from/this/mirro...

贡献一个基于flash的页面不刷新更新

一个比较简单的例子,做复杂了可以实现flash+xml的条件判断来及时...

当更换图片时,不能立即更换,只有鼠标...

如题

有人研究过"百度"搜索的排名...

有人研究过"百度"搜索的排名竞价系统吗? 现在我正在做类式的...

数据库查询语句求教

如何确定我搜索的字段中的值只能唯一? select distinct * ...

to 地主:500元及以下的128M显卡什么样...

有人推荐“巴达克:只要499元,128MB的FX5200”

php 中有什么好方法实现重定向

?php 中有什么好方法实现重定向

用户在线

哪位再说一下用户在线的问题。 我看了精华区的讨论,但我不是很...

关于MD5加密!有什么用途呢?比如一个p...

比如我在pass字段中存入经过 md5加密后的密码! 只不过是把用户...

上传图片的问题!

Warning: getimagesize(WRPq_1.jpg): failed to open stream: No...

[]