Crypto algorithm implementations for the 65816
Go to file
Stephen Heumann 58a9c564ae Implement "KDF in Counter Mode" from NIST SP 800-108.
This is currently instantiated with HMAC-SHA256 as the pseudo-random function, but is implemented using a template so that other PRFs could also be used.
2024-04-15 19:48:42 -05:00
.gitignore Update .gitignore file. 2023-11-30 18:35:36 -06:00
LICENSE Implement AES-CMAC. 2024-04-14 22:17:07 -05:00
Makefile Implement "KDF in Counter Mode" from NIST SP 800-108. 2024-04-15 19:48:42 -05:00
README.md Implement RC4. 2023-12-01 21:39:40 -06:00
aes.asm Fix typos in comments. 2017-11-26 09:25:41 -06:00
aes.h Implement AES-CMAC. 2024-04-14 22:17:07 -05:00
aes.macros state -> context 2017-06-29 16:52:34 -05:00
aescbctest.c Mention sources of AES test vectors. 2017-11-25 21:27:25 -06:00
aescmac.c Implement AES-CMAC. 2024-04-14 22:17:07 -05:00
aescrypt.c Add copyright notices and comments. 2017-07-02 18:41:21 -05:00
aesctrtest.c Mention sources of AES test vectors. 2017-11-25 21:27:25 -06:00
aesmodes.c Add copyright notices and comments. 2017-07-02 18:41:21 -05:00
aestest.c Mention sources of AES test vectors. 2017-11-25 21:27:25 -06:00
cksumcommon.h Don't call srand unless we're actually randomizing read sizes. 2017-11-19 23:47:30 -06:00
cmactest.c Implement AES-CMAC. 2024-04-14 22:17:07 -05:00
hmacimpl.h Update HMAC-MD5 code to support processing a message in multiple parts. 2023-12-10 15:09:57 -06:00
hmactest.c Add and use result macros for all HMACs. 2024-04-15 18:39:36 -05:00
kdfimpl.h Implement "KDF in Counter Mode" from NIST SP 800-108. 2024-04-15 19:48:42 -05:00
md4.asm Implement MD4. 2023-11-30 18:35:11 -06:00
md4.cc Implement MD4. 2023-11-30 18:35:11 -06:00
md4.h Add and use result macros for all HMACs. 2024-04-15 18:39:36 -05:00
md4.macros Implement MD4. 2023-11-30 18:35:11 -06:00
md4sum.c Implement MD4. 2023-11-30 18:35:11 -06:00
md4test.c Implement MD4. 2023-11-30 18:35:11 -06:00
md5.asm Force MD5 tables to be page-aligned, which should save a cycle in some cases. 2017-07-04 14:37:17 -05:00
md5.cc Implement HMAC-MD5, HMAC-SHA1, and HMAC-SHA256. 2023-11-29 20:03:37 -06:00
md5.h Add and use result macros for all HMACs. 2024-04-15 18:39:36 -05:00
md5.macros Correct a comment. 2023-11-30 18:35:23 -06:00
md5sum.c Use a common template for all the file checksum programs. 2017-11-19 22:43:31 -06:00
md5test.c Add implementation of MD5 hash function. 2017-07-04 12:15:00 -05:00
pagealign.asm Force MD5 tables to be page-aligned, which should save a cycle in some cases. 2017-07-04 14:37:17 -05:00
rc4.asm Implement RC4. 2023-12-01 21:39:40 -06:00
rc4.cc Implement RC4. 2023-12-01 21:39:40 -06:00
rc4.h Implement RC4. 2023-12-01 21:39:40 -06:00
rc4test.c Implement RC4. 2023-12-01 21:39:40 -06:00
rotate.macros Add comments and copyright notices, and rename chunk to block. 2017-07-01 17:53:49 -05:00
sha1.asm Add comments and copyright notices, and rename chunk to block. 2017-07-01 17:53:49 -05:00
sha1.cc Implement HMAC-MD5, HMAC-SHA1, and HMAC-SHA256. 2023-11-29 20:03:37 -06:00
sha1.h Add and use result macros for all HMACs. 2024-04-15 18:39:36 -05:00
sha1.macros Typos 2017-07-02 22:54:18 -05:00
sha1sum.c Use a common template for all the file checksum programs. 2017-11-19 22:43:31 -06:00
sha1test.c Add comments and copyright notices, and rename chunk to block. 2017-07-01 17:53:49 -05:00
sha256.asm Add initialization function to permit computation of SHA-224 hashes. 2017-07-03 23:40:36 -05:00
sha256.cc Implement "KDF in Counter Mode" from NIST SP 800-108. 2024-04-15 19:48:42 -05:00
sha256.h Implement "KDF in Counter Mode" from NIST SP 800-108. 2024-04-15 19:48:42 -05:00
sha256.macros Remove unused macros. 2017-07-03 23:05:51 -05:00
sha256sum.c Use a common template for all the file checksum programs. 2017-11-19 22:43:31 -06:00
sha256test.c Work around ORCA/C bug that affects lower optimization levels. 2017-07-05 12:24:37 -05:00

README.md

65816 Cryptographic & Hash Libraries

This package contains libraries implementing cryptographic algorithms for the 65816, suitable for use on the Apple IIgs and potentially also other 65816-based systems. Currently, it includes implementations of AES and RC4 encryption and decryption (in lib65816crypto), and of the MD4, MD5, SHA-1, and SHA-256 hash functions (in lib65816hash). The core algorithms for each of these are written in carefully optimized assembly code, and they can generally process at least several thousand bytes per second on a 2.8 MHz Apple IIgs.

Using the Libraries

These libraries can easily be used from ORCA/C, or from ORCA/M or other assemblers that permit linking to OMF libraries. (With appropriate glue code, they could also be used from other languages.) Refer to the included header files for documentation on how to call them. Note that each algorithm uses a 'context' structure which must be in bank 0. This can be allocated on the stack (e.g. by using a local variable in C), although maximum performance will be obtained if it is page-aligned.

If you are calling these algorithms from assembly language, simply follow the usual conventions for calling ORCA/C code: push the arguments on the stack in reverse order, and then JSL to the function. The data bank must be set to the bank containing the library code (which is in the default, blank-named load segment), and the functions must be called in full native mode.

If you use these libraries in your program, you will need to link them into it. You can either place the libraries in the Libraries directory of your ORCA installation, or place them somewhere else and specify them on the command line when linking your program. When using certain algorithms (currently AES and MD5), you may also need to include pagealign.root as the first file on the linker command line. This file contains no code, but simply specifies that the default load segment should be page-aligned. This is needed because those algorithms include data tables that are page-aligned to maximize performance.

Note that some of the algorithms implemented in this package (including RC4, MD4, MD5, and SHA-1) have known security weaknesses. If you are using any of these algorithms in a situation where security is important, you should refer to up-to-date cryptanalytic results and advice to determine whether they are appropriate for your application.

Building the Libraries

If you want to build these libraries yourself, you will need ORCA/M and ORCA/C. To ensure everything builds correctly, I recommend using ORCA/C 2.2.0 or later. The included Makefile is set up to build the libraries and test programs on a modern system using Golden Gate, but they could also be build under the ORCA shell or GNO with a suitable build script.

File Checksum Programs

This package also includes versions of the md5sum, sha1sum, and sha256sum programs, which can be run under the ORCA shell or GNO. These utilities compute file checksums using the corresponding hash algorithms and can be useful for verifying the integrity of files.