操纵80位数据类型使用C [英] Manipulating 80 bits datatype in C

查看:207
本文介绍了操纵80位数据类型使用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施一些C加密算法涉及的80位密钥。
特定操作涉及旋转换档位的密钥x号。

I'm implementing some cryptographic algorithm in C which involves an 80 bits key. A particular operation involves a rotate shifting the key x number of bits.

我试过长双类型,如果我没看错是80bits,但不与bitshift运营工作。

I've tried the long double type which if I'm not wrong is 80bits, but that doesn't work with the bitshift operator.

我能想出的唯一的选择是使用10元字符数组有一些复杂的循环和if-else语句。

The only alternative I can come up with is to use a 10 element char array with some complicated looping and if-else.

我的问题是,是否有携带这种出一些简单而有效的方法。

My question is whether there's some simple and efficient way of carrying this out.

感谢。

推荐答案

不幸的是,你需要一个BIGNUM库。而C原始数据类型都支持80位彩车它实际上并没有做你想做的。

Sadly you need a bignum library. While C native data types have support for 80 bit floats it doesn't actually do what you want.

有可能像 GMP相关联东西,甚至用一个不太理想的方法,如10字符数组或两个数字的长和短(64位和16位的整数)。

It is possible to link something like GMP or even use a less desirable approaches like 10 character array or two numbers a long and short (64bit and 16bit integers).

也不是特别pretty,但他们做的工作,如果你打算使用这个任何东西,但一类, GMP 是要走的路。否则,你可能最终与定时,这可以code攻击周围的整个混乱,但它可以得到真是可恶,真快。

Neither is particularly pretty but they do work and if you're planning on using this for anything but a class, GMP is the way to go. Otherwise you could end up with a whole mess of timing attacks which you could code around but it could get really nasty, real quick.

这篇关于操纵80位数据类型使用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆