|
[求助]椭圆曲线数字签名中基点的阶的问题
“如果群的阶#E为素数,则群中每一个元都可以由另一个元生成, 每个元也可以生 成其它元, 而且每个元的阶均为#E, 即群的阶为基点的阶。” 这是我在一篇文献中看到的一句话,能解释下么? |
|
SHA-1计算出的摘要怎样转换为一个整数?
[QUOTE=exile;904362]state[0]^state[1]^state[2]^state[3]^state[4]不就行了。[/QUOTE] state[0]^state[1]^state[2]^state[3]^state[4]得出一个32位的值来代替160位的消息摘要进行签名,是么? 我刚学数字签名,所以还不懂,很感谢你的回答 |
|
SHA-1计算出的摘要怎样转换为一个整数?
[QUOTE=skyaegean;903984]不知道楼主用啥语言写的,一下是一段java代码,可以参考一下最后一段,将数组合并 public class sha1 { private final int[] abcde = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2...[/QUOTE] 谢谢,我在写一个数字签名的代码,用的SHA-1用C写的,java我没学耶嘻嘻,下面是SHA-1的代码,能帮我想想连接五个分块的C代码么…… #include <STDIO.H> unsigned int state[5]; unsigned int f1(unsigned int B, unsigned int C, unsigned int D) { return (B&C)|(~B&D); } unsigned int f2(unsigned int B, unsigned int C, unsigned int D) { return B^C^D; } unsigned int f3(unsigned int B, unsigned int C, unsigned int D) { return (B&C)|(B&D)|(C&D); } unsigned int f4(unsigned int B, unsigned int C, unsigned int D) { return B^C^D; } void Init() { state[0] = 0x67452301; state[1] = 0xefcdab89; state[2] = 0x98badcfe; state[3] = 0x10325476; state[4] = 0xc3d2e1f0; } void shaTran(unsigned char * buf,unsigned int * state) { int i,j; unsigned int A,B,C,D,E,temp; unsigned int K[4]; unsigned int W[80]; unsigned char * p = (unsigned char *)W; A = state[0]; B = state[1]; C = state[2]; D = state[3]; E = state[4]; K[0] = 0x5a827999; K[1] = 0x6ed9eba1; K[2] = 0x8f1bbcdc; K[3] = 0xca62c1d6; for(i=0;i<16;i++) { j = 4*i; p[j+3] = buf[j]; p[j+2] = buf[j+1]; p[j+1] = buf[j+2]; p[j] = buf[j+3]; } for(i=16;i<80;i++) { W[i] = ((W[i-16]^W[i-14]^W[i-8]^W[i-3])<<1) | ((W[i-16]^W[i-14]^W[i-8]^W[i-3])>>31); } for(i=0;i<20;i++) { temp = E + f1(B,C,D) + ((A<<5)|(A>>27)) + W[i] + K[0]; E = D; D = C; C = (B<<30)|(B>>2); B = A; A = temp; } for(i=20;i<40;i++) { temp = E + f2(B,C,D) + ((A<<5)|(A>>27)) + W[i] + K[1]; E = D; D = C; C = (B<<30)|(B>>2); B = A; A = temp; } for(i=40;i<60;i++) { temp = E + f3(B,C,D) + ((A<<5)|(A>>27)) + W[i] + K[2]; E = D; D = C; C = (B<<30)|(B>>2); B = A; A = temp; } for(i=60;i<80;i++) { temp = E + f4(B,C,D) + ((A<<5)|(A>>27)) + W[i] + K[3]; E = D; D = C; C = (B<<30)|(B>>2); B = A; A = temp; } state[0] += A; state[1] += B; state[2] += C; state[3] += D; state[4] += E; } void sha(unsigned char *buf, int len, unsigned int * state, unsigned int f1,unsigned int f2) { int i; unsigned int floop1,floop2; unsigned char flen[8]; unsigned char *p1 = (unsigned char *)&floop1; unsigned char *p2 = (unsigned char *)&floop2; floop1 = f1; floop2 = f2; floop2 = floop2 + (unsigned int)(len*8); printf("floop1 = %08x\n",floop1); printf("floop2 = %08x\n",floop2); for(i=0; i<4; i++) { flen[3-i] = *p1; flen[7-i] = *p2; p1++; p2++; } if(len<56) { buf[len] = 0x80; for(i=len+1; i<56; i++) { buf[i] = 0x00; } for(i=56; i<64; i++) { buf[i] = flen[i-56]; } shaTran(buf,state); } else { buf[len] = 0x80; for(i=len+1; i<64; i++) { buf[i] = 0x00; } shaTran(buf,state); for(i=0; i<56; i++) buf[i] = 0x00; for(i=56; i<64; i++) { buf[i] = flen[i-56]; } shaTran(buf,state); } } int main() { unsigned char buf[64]; FILE * file; int len; unsigned int floop1,floop2; floop1 = floop2 = 0; Init(); if (!(file = fopen("a.txt", "rb"))) { printf("can not open file!!!\n"); return -1; } while(!feof(file)) { len=fread(buf,1,64,file); if(ferror(file)) { printf("read file error!!!\n"); return -1; } if(len == 64) { if((floop1 == 0xffffffff) && (floop2 == 0xfffffe00)) { printf("file larger than 2exp(64)"); return -1; } if(floop2 != 0xfffffe00)floop2+=512; else { floop1++; floop2 = 0; } shaTran(buf,state); } else { sha(buf,len,state,floop1,floop2); } } printf("%08x %08x %08x %08x %08x\n",state[0],state[1],state[2],state[3],state[4]); return 0; } |
|
SHA-1计算出的摘要怎样转换为一个整数?
能具体点么,大数,进行连接,怎么连接我不懂…… |
|
SHA-1计算出的摘要怎样转换为一个整数?
那最终得出的是一个32位的值? |
|
[求助]学习汇编的进来!
我也是这么认为的……只是不知道LZ发了个狂怒的表情是什么意思…… |
|
[求助]学习汇编的进来!
我发的有什么问题么? |
|
[求助]学习汇编的进来!
《王爽 汇编语言第二版》的课后题答案 |
|
[讨论]crackme4.exe (inside use only, for networking)
是福建师范大学福清分校~ |
|
[分享]愛說「隨便」嘛? 心理專家替你解讀
词都要适合场合适合情境地用的,“随便”也有好用的地方啦。比如,你问我要吃什么冰淇凌,我会说蒙牛“随便”的…… |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值