From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1922c4740861327c X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Bit manipulation facilities in Ada Date: 1998/11/23 Message-ID: #1/1 X-Deja-AN: 414947555 References: <36573C4D.DA431821@physics.purdue.edu> Organization: The Mitre Corp., Bedford, MA. Newsgroups: comp.lang.ada Date: 1998-11-23T00:00:00+00:00 List-Id: In article <36573C4D.DA431821@physics.purdue.edu> "Robert T. Sagris" writes: > I'm thinking about taking an Data Security and Encryption course. > The language for programming projects is open to the students. > I was wondering if any one could recommend any books that demonstrate > low level bit manipulation in Ada. I think that the problem is that bit manipulation is not low-level in Ada, it is high level, but just as efficient. For most modern symmetric key algorithms that use Feistel networks you end up writing one line of code that looks very much like the original definition: Block(1) := F(Block(2) xor Key(N)) xor Count; (Chosen to look real but not from any known algorithm. ;-) > None of which seem to cover this in any detail. Once you know that in Ada, Boolean operations are supported on Booleans and arrays of Booleans, and in Ada 95 on unsigned integer types, what more do you need to know. (Other than in symmetric block algorithms, you often want to declare the block type as an array of sub-blocks, and the sub-blocks as unsigned or boolean arrays depending on the algorithm. > The Professor has already recommended C for its built in Bit operators. > But I would like to try it in Ada, as I've never used in a class. > I could use the practice. The standard random number packages in Ada 95 will do fine for testing algorithms, but if you really need cryptographic security, you will need to collect your own random bits, and possibly use the built-in PRNG for whitening. Whitening is the process of taking possibly biased (non-pseudo) random data and converting it into fewer, but unbiased random bits. There is one other thing you may need. In public key encryption, you often need a way to do arithmetic on very large integer types. Most Ada compilers supply such a package, as they need it internally, but you may need to add X to the power Y mod Z as a primitive to get any reasonable performance. The best choice is to use a cryptographic bignum package and create a (high-level) interface to it. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...