Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE Cipher = POINTER TO CipherRec; TYPE CipherRec = RECORD (PersistentDisciplines.ObjectRec) END; TYPE CryptProc = PROCEDURE (in: Streams.Stream; key: Cipher; length: INTEGER; out: Streams.Stream) : BOOLEAN; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) encrypt, decrypt : CryptProc; END; PROCEDURE Init(key: Cipher; if: Interface); PROCEDURE Encrypt(in: Streams.Stream; key: Cipher; out: Streams.Stream) : BOOLEAN; PROCEDURE Decrypt(in: Streams.Stream; key: Cipher; out: Streams.Stream) : BOOLEAN; PROCEDURE EncryptPart(in: Streams.Stream; key: Cipher; length: INTEGER; out: Streams.Stream) : BOOLEAN; PROCEDURE DecryptPart(in: Streams.Stream; key: Cipher; length: INTEGER; out: Streams.Stream) : BOOLEAN;
An implementation of Ciphers must provide two procedures for encrypting and decrypting streams. Neither encrypt nor decrypt may be given as NIL. Init connects these methods by the interface if with the cipher key. Note that an implementation of a specific crypto system should not directly depend on Ciphers but instead on more appropriate abstractions like AsymmetricCiphers, BlockCiphers or StreamCiphers.
Encrypt encrypts the stream in using the cipher key and writes the output onto the stream out. Decrypt decrypts the stream in. EncryptPart and DecryptPart operate only on the next length bytes of the input stream. In case of any error FALSE is returned, otherwise TRUE.
Oberon || Library || Module Index || Search Engine || Definition || Module