2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* LibTomCrypt, modular cryptographic library -- Tom St Denis
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * LibTomCrypt is a library that provides various cryptographic
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * algorithms in a highly modular and flexible manner.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * The library is free for all purposes without any express
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * guarantee it works.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "tomcrypt.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  @file crypt_sizes.c
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  Make various struct sizes available to dynamic languages
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  like Python - Larry Bugbee, February 2013
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  LB - Dec 2013 - revised to include compiler define options
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								*/
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								typedef struct {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const char *name;
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const unsigned int size;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								} crypt_size;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define _SZ_STRINGIFY_S(s) { #s, sizeof(struct s) }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define _SZ_STRINGIFY_T(s) { #s, sizeof(s) }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static const crypt_size _crypt_sizes[] = {
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // hash state sizes
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(ltc_hash_descriptor),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(hash_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SHA256
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(sha256_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SHA512
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(sha512_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_WHIRLPOOL
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(whirlpool_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MD2
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(md2_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MD4
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(md4_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MD5
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(md5_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RIPEMD128
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rmd128_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RIPEMD160
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rmd160_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RIPEMD256
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rmd256_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RIPEMD320
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rmd320_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SHA1
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(sha1_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_TIGER
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(tiger_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CHC_HASH
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(chc_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // block cipher key sizes
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(ltc_cipher_descriptor),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_ANUBIS
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(anubis_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CAMELLIA
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(camellia_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_BLOWFISH
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(blowfish_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CAST5
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(cast5_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_DES
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(des_key),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(des3_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_KASUMI
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(kasumi_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_KHAZAD
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(khazad_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_KSEED
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(kseed_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MULTI2
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(multi2_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_NOEKEON
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(noekeon_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RC2
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rc2_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RC5
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rc5_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RC6
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rc6_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SKIPJACK
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(skipjack_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_XTEA
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(xtea_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RIJNDAEL
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rijndael_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SAFER
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(safer_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SAFERP
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(saferp_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_TWOFISH
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(twofish_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // mode sizes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CBC_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_CBC),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CFB_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_CFB),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CTR_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_CTR),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_ECB_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_ECB),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_F8_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_F8),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_LRW_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_LRW),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_OFB_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(symmetric_OFB),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // MAC sizes            -- no states for ccm, lrw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_F9_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(f9_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_HMAC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(hmac_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_OMAC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(omac_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_PELICAN
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(pelican_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_PMAC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(pmac_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_XCBC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(xcbc_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_OCB_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(ocb_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_OCB3_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(ocb3_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_GCM_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(gcm_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_EAX_MODE
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(eax_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_CCM_MODE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// not defined
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LRW_MODE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// not defined
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // asymmetric keys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MRSA
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(rsa_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MDSA
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(dsa_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MDH
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(dh_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MECC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(ltc_ecc_set_type),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(ecc_key),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(ecc_point),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-17 10:49:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_MKAT
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(katja_key),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // prng state sizes
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(ltc_prng_descriptor),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_T(prng_state),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_FORTUNA
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(fortuna_prng),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_RC4
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(rc4_prng),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_SOBER128
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(sober128_prng),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifdef LTC_YARROW
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 15:27:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _SZ_STRINGIFY_S(yarrow_prng),
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // sprng has no state as it uses other potentially available sources
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // like /dev/random.  See Developers Guide for more info.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* crypt_get_size()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * sizeout will be the size (bytes) of the named struct or union
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * return -1 if named item not found
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int crypt_get_size(const char* namein, unsigned int *sizeout) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    int i;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 14:09:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (i=0; i<count; i++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (strcmp(_crypt_sizes[i].name, namein) == 0) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            *sizeout = _crypt_sizes[i].size;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return -1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* crypt_list_all_sizes()
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * if names_list is NULL, names_list_size will be the minimum
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *     size needed to receive the complete names_list
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * if names_list is NOT NULL, names_list must be the addr with
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *     sufficient memory allocated into which the names_list
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *     is to be written.  Also, the value in names_list_size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *     sets the upper bound of the number of characters to be
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *     written.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * a -1 return value signifies insufficient space made available
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    int i;
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    unsigned int total_len = 0;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 14:09:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    char number[32];
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    int number_len;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    /* calculate amount of memory required for the list */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (i=0; i<count; i++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        total_len += strlen(_crypt_sizes[i].name) + 1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        /* the above +1 is for the commas */
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 14:09:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if ((number_len < 0) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ((unsigned int)number_len >= sizeof(number)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          return -1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        total_len += strlen(number) + 1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        /* this last +1 is for newlines (and ending NULL) */
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (names_list == NULL) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        *names_list_size = total_len;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (total_len > *names_list_size) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return -1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        /* build the names list */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        char *ptr = names_list;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (i=0; i<count; i++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            strcpy(ptr, _crypt_sizes[i].name);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ptr += strlen(_crypt_sizes[i].name);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            strcpy(ptr, ",");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ptr += 1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-29 23:30:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            strcpy(ptr, number);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ptr += number_len;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            strcpy(ptr, "\n");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ptr += 1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        /* to remove the trailing new-line */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ptr -= 1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-06 15:46:01 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        *ptr = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 13:58:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/* $Source$ */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* $Revision$ */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* $Date$ */
							 |