OpenSSL对称加密算法中怎么样添加新算法for(i=0; i<8;> iv[i] = in[i];
}
/*final block*/
if(l != -8)
{
decrypt(in, buf, key, &len);
for(i=0; i out[i] = buf[i] ^ iv[i];
for(i=0; i<8;> iv[i] = in[i];
}
}
l = 0;
i = 0;
}
void cfb64_encrypt(const unsigned char *in, unsigned char *out,
long length, const KEY *key, unsigned char *iv, int *num, int enc)
{/* 密码反馈模式 */
register long l = length;
unsigned char buf[8];
register int i, save = 0, n = *num;/*start from previously saved processing position*/
int len = 8;
/*restore from previously saved iv*/
for(i=n; i<8;> buf[i] = iv[i];
if(enc)
{
while(l--)
{
if(n == 0)
{
encrypt(iv, buf, key, &len);
save = 1;
}
*(out++) = iv[n] = *(in++) ^ buf[n];
n = (n+1)&0x07;
}
}
else
{
while(l--)
{
if(n == 0)
{
encrypt(iv, buf, key, &len);
save = 1;
}
*(out++) = (iv[n]=*(in++)) ^ buf[n];
n = (n+1)&0x07;
}
}
if(save)/*store encrypted data into iv for next encryption*/
for(i=n; i<8;> iv[i] = buf[i];
/* cfb加密输出得结果作为下次得IV, in与加密IV的结果作异或运算的结果作为cfb加密的输出 */
*num = n;/*store current processing position as entry of next encryption*/
save = i = n = 0;
}
void ofb64_encrypt(const unsigned char *in, unsigned char *out,
long length, const KEY *key, unsigned char *iv, int *num)
{/* 输出反馈模式 */
register long l = length;
register int i, n = *num;/*start from previously saved processing position*/
int len = 8;
unsigned char buf[8];
/*restore from previously saved iv*/
上一篇:Linux下基于路由策略的IP地址控制实例 下一篇:安全多方位 Linux系统守护进程详解 更多相关文章
|
推荐文章
精彩文章
|