Codec 1.0

Dominic Steinitz dominic.steinitz at blueyonder.co.uk
Mon Jan 10 16:25:41 EST 2005


On Monday 10 Jan 2005 10:42 am, Simon Marlow wrote:
> On 09 January 2005 12:43, Dominic Steinitz wrote:
> > base64 encoding / decoding should probably be included in Codec.Utils
> > (I've seen copies of the same code all over the place) and if anyone
> > has the time, they are very welcome to add it.
> >
> > I'd also welcome feedback on whether this is the right place in the
> > hierarchy for such a package and modules.
>
> We generally try to avoid names like 'Utils', if at all possible.
> Sometimes you really do need a bag of miscellaneous bits though (eg.
> Foreign.Marshal.Utils).
>
> For base64, the hierarchy design has this in Codec.Binary.Base64:
>
>   http://www.haskell.org/~simonmar/lib-hierarchy.html
>
> Cheers,
> 	Simon

Simon, 

Thanks for this. I'd forgotten about the document describing the hierarchy. 
The Codec.Utils exports:

type Octet = Word8
msb :: Int
fromTwosComp :: Integral a => [Octet] -> a
toOctets :: Integral a => a -> a -> [Octet]
fromOctets :: Num a => a -> [Octet] -> a
i2osp :: Integral a => Int -> a -> [Octet]

Thinking about it, i2osp should go in Codec.Encryption.RSA as it's specific to 
RSA.

I'm not clear about the rest. How about Codec.Integral for toOctets, 
fromOctets and fromTwosComp? I could probably live without Octet (although 
quite a few standards are defined using the term octet) but I find myself 
needing msb (most significant bit) in quite a few places. Where would that 
go?

Whilst on the subject, why is BER in Network? BER is one of many encodings for 
ASN.1 and use of BER is not limited to networks; it is used heavily in 
cryptography, for example, in PKCS#8 and X.509. I'd suggest Codec.ASN1.BER, 
Codec.ASN1.TLV for the functions that take octets and turn them into Tags, 
Lengths and Values and Codec.ASN1.ASN1 for real ASN.1 types and functions.

Furthermore, if I follow the hierarchy for the existing cryptography library 
then I would end up with Data.Digest for MD5 and SHA-1. What would the 
package name for these be? Digest? What should the package name be for DES, 
AES, Blowfish and RSA be? Still crypto or Encryption?

In general is there a relationship between modules and their names and package 
names?

Dominic.



More information about the Libraries mailing list