-
-
[求助]RSA of DELPHI
-
发表于: 2010-5-25 20:29 5723
-
program t; {$APPTYPE CONSOLE} uses Windows,SysUtils; type BN_STRUCT = record d: Pointer; top, dmax, neg, flags: integer; end; BIGNUM = ^BN_STRUCT; PBIGNUM = ^BIGNUM; RSA_STRUCT = record pad, version: integer; meth: pointer; n, e, d, p, q, dmp1, dmpq1, iqmp: BIGNUM; end; RSA = ^RSA_STRUCT ; function BN_new: BIGNUM; cdecl; external 'libeay32.dll'; function RSA_new: RSA; cdecl; external 'libeay32.dll'; function BN_bin2bn(s: PChar; len: integer; ret: BIGNUM): BIGNUM; cdecl;external 'libeay32.dll'; function RSA_public_encrypt(Len: integer; Source, Dest: Pointer;rsa: RSA; padding: integer): integer; cdecl; external 'libeay32.dll'; const SEC_MODULUS_SIZE = 64; SEC_EXPONENT_SIZE = 4; smd5 : array[0..SEC_MODULUS_SIZE -1 ] of Byte = ( $01, $01, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00, $81, $2A, $14, $9C, $B7, $64, $78, $F2, $0B, $96, $11, $AC, $3E, $DC, $70, $2F); ekey :array [0..3] of Byte = ($01, $02 ,$03,$04); nkey :array[0..SEC_MODULUS_SIZE -1 ] of Byte=( $59, $B0, $19, $37, $F7, $4E, $AC, $96, $4D, $61, $DC, $FC, $64, $AD, $55, $AE, $7C, $CC, $27, $A7, $32, $CB, $BD, $35, $A2, $9F, $CE, $B9, $80, $48, $8B, $F1, $49, $E1, $8B, $6F, $B1, $F9, $02, $E1, $59, $4B, $E4, $B0, $20, $F8, $18, $DA, $B7, $3D, $83, $16, $7D, $3F, $D1, $1B, $C6, $45, $98, $EE, $64, $F1, $4E, $CA); var e,n:BIGNUM; s_key:RSA ; code:array [0..SEC_MODULUS_SIZE -1] of Byte; begin n := BN_new; BN_bin2bn(@nkey,SEC_MODULUS_SIZE, n); e := BN_new; BN_bin2bn(@ekey, SEC_EXPONENT_SIZE, e); s_key := RSA_new; s_key.n := n; s_key.e := e; RSA_public_encrypt(SEC_MODULUS_SIZE,@smd5,@code,s_key, 3); end.
在OD里查看 code全为0 也就是没有成功加密。怎么回事。我很迷茫.
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
- [求助]RSA of DELPHI 5724
- [求助]请教一个数的转换 4921
- [求助]这个结构怎么转换为DELPHI 3914
- [己解决]请教个关于DLL调试问题 4557
- [讨论]关于RSA TOOL2 与 BIGINT 4830
看原图
赞赏
雪币:
留言: