clean up/trim trailing spaces
This commit is contained in:
parent
a6b6884982
commit
e628fb9203
@ -21,34 +21,34 @@
|
|||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int rc;
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// given a specific constant name, get and print its value
|
// given a specific constant name, get and print its value
|
||||||
char name[] = "CTR_COUNTER_BIG_ENDIAN";
|
char name[] = "CTR_COUNTER_BIG_ENDIAN";
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
rc = crypt_get_constant(name, &value);
|
if (crypt_get_constant(name, &value) != 0)
|
||||||
printf(" %s is %d \n", name, value);
|
exit(EXIT_FAILURE);
|
||||||
printf("\n");
|
printf("\n %s is %d \n\n", name, value);
|
||||||
|
|
||||||
// get and print the length of the names (and values) list
|
// get and print the length of the names (and values) list
|
||||||
char *names_list;
|
char *names_list;
|
||||||
unsigned long names_list_len;
|
unsigned long names_list_len;
|
||||||
|
|
||||||
rc = crypt_list_all_constants(NULL, &names_list_len);
|
if (crypt_list_all_constants(NULL, &names_list_len) != 0)
|
||||||
printf(" need to allocate %lu bytes \n", names_list_len);
|
exit(EXIT_FAILURE);
|
||||||
printf("\n");
|
printf(" need to allocate %lu bytes \n\n", names_list_len);
|
||||||
|
|
||||||
// get and print the names (and values) list
|
// get and print the names (and values) list
|
||||||
names_list = malloc(names_list_len);
|
if ((names_list = malloc(names_list_len)) == NULL)
|
||||||
rc = crypt_list_all_constants(names_list, &names_list_len);
|
exit(EXIT_FAILURE);
|
||||||
printf(" supported constants: \n%s \n", names_list);
|
if (crypt_list_all_constants(names_list, &names_list_len) != 0)
|
||||||
printf("\n");
|
exit(EXIT_FAILURE);
|
||||||
|
printf(" supported constants:\n\n%s\n\n", names_list);
|
||||||
|
free(names_list);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Source: $ */
|
/* $Source$ */
|
||||||
/* $Revision: $ */
|
/* $Revision$ */
|
||||||
/* $Date: $ */
|
/* $Date$ */
|
||||||
|
@ -20,27 +20,23 @@
|
|||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int rc;
|
int rc;
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// given a specific size name, get and print its size
|
// given a specific size name, get and print its size
|
||||||
char name[] = "ecc_key_struct_size";
|
char name[] = "ecc_key_struct_size";
|
||||||
int size;
|
int size;
|
||||||
rc = crypt_get_size(name, &size);
|
rc = crypt_get_size(name, &size);
|
||||||
printf(" %s is %d \n", name, size);
|
printf("\n size of '%s' is %d \n\n", name, size);
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// get and print the length of the names (and sizes) list
|
// get and print the length of the names (and sizes) list
|
||||||
char *sizes_list;
|
char *sizes_list;
|
||||||
unsigned long sizes_list_len;
|
unsigned long sizes_list_len;
|
||||||
rc = crypt_list_all_sizes(NULL, &sizes_list_len);
|
rc = crypt_list_all_sizes(NULL, &sizes_list_len);
|
||||||
printf(" need to allocate %lu bytes \n", sizes_list_len);
|
printf(" need to allocate %lu bytes \n\n", sizes_list_len);
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// get and print the names (and sizes) list
|
// get and print the names (and sizes) list
|
||||||
sizes_list = malloc(sizes_list_len);
|
sizes_list = malloc(sizes_list_len);
|
||||||
rc = crypt_list_all_sizes(sizes_list, &sizes_list_len);
|
rc = crypt_list_all_sizes(sizes_list, &sizes_list_len);
|
||||||
printf(" supported sizes: %s \n", sizes_list);
|
printf(" supported sizes:\n\n%s\n\n", sizes_list);
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,12 +51,10 @@ int crypt_fsa(void *mp, ...);
|
|||||||
|
|
||||||
/* ---- Dynamic language support ---- */
|
/* ---- Dynamic language support ---- */
|
||||||
int crypt_get_constant(const char* namein, int *valueout);
|
int crypt_get_constant(const char* namein, int *valueout);
|
||||||
int crypt_list_all_constants(char *names_list,
|
int crypt_list_all_constants(char *names_list, unsigned long *names_list_size);
|
||||||
unsigned long *names_list_size);
|
|
||||||
|
|
||||||
int crypt_get_size(const char* namein, int *sizeout);
|
int crypt_get_size(const char* namein, int *sizeout);
|
||||||
int crypt_list_all_sizes(char *names_list,
|
int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size);
|
||||||
unsigned long *names_list_size);
|
|
||||||
|
|
||||||
void init_LTM(void);
|
void init_LTM(void);
|
||||||
void init_TFM(void);
|
void init_TFM(void);
|
||||||
|
@ -47,27 +47,27 @@ crypt_constant _crypt_constants[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDIAN_LITTLE
|
#ifdef ENDIAN_LITTLE
|
||||||
{"ENDIAN_LITTLE", 1}, // true
|
{"ENDIAN_LITTLE", 1},
|
||||||
#else
|
#else
|
||||||
{"ENDIAN_LITTLE", 0}, // false
|
{"ENDIAN_LITTLE", 0},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDIAN_BIG
|
#ifdef ENDIAN_BIG
|
||||||
{"ENDIAN_BIG", 1}, // true
|
{"ENDIAN_BIG", 1},
|
||||||
#else
|
#else
|
||||||
{"ENDIAN_BIG", 0}, // false
|
{"ENDIAN_BIG", 0},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDIAN_32BITWORD
|
#ifdef ENDIAN_32BITWORD
|
||||||
{"ENDIAN_32BITWORD", 1}, // true
|
{"ENDIAN_32BITWORD", 1},
|
||||||
#else
|
#else
|
||||||
{"ENDIAN_32BITWORD", 0}, // false
|
{"ENDIAN_32BITWORD", 0},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENDIAN_64BITWORD
|
#ifdef ENDIAN_64BITWORD
|
||||||
{"ENDIAN_64BITWORD", 1}, // true
|
{"ENDIAN_64BITWORD", 1},
|
||||||
#else
|
#else
|
||||||
{"ENDIAN_64BITWORD", 0}, // false
|
{"ENDIAN_64BITWORD", 0},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,21 +98,20 @@ int crypt_get_constant(const char* namein, int *valueout) {
|
|||||||
* written.
|
* written.
|
||||||
* a -1 return value signifies insufficient space made available
|
* a -1 return value signifies insufficient space made available
|
||||||
*/
|
*/
|
||||||
int crypt_list_all_constants(char *names_list,
|
int crypt_list_all_constants(char *names_list, unsigned long *names_list_size) {
|
||||||
unsigned long *names_list_size) {
|
|
||||||
int i;
|
int i;
|
||||||
unsigned long total_len = 0;
|
unsigned long total_len = 0;
|
||||||
char number[10];
|
char number[10];
|
||||||
int number_len;
|
int number_len;
|
||||||
int count = sizeof(_crypt_constants) / sizeof(crypt_constant);
|
int count = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]);
|
||||||
|
|
||||||
/* calculate amount of memory required for the list */
|
/* calculate amount of memory required for the list */
|
||||||
for (i=0; i<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
total_len += strlen(_crypt_constants[i].name) + 1;
|
total_len += strlen(_crypt_constants[i].name) + 1;
|
||||||
// the above +1 is for the commas
|
/* the above +1 is for the commas */
|
||||||
sprintf(number,"%lu",_crypt_constants[i].value);
|
sprintf(number,"%lu",_crypt_constants[i].value);
|
||||||
total_len += strlen(number) + 1;
|
total_len += strlen(number) + 1;
|
||||||
// this last +1 is for newlines (and ending NULL)
|
/* this last +1 is for newlines (and ending NULL) */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names_list == NULL) {
|
if (names_list == NULL) {
|
||||||
@ -135,13 +134,14 @@ int crypt_list_all_constants(char *names_list,
|
|||||||
strcpy(ptr, "\n");
|
strcpy(ptr, "\n");
|
||||||
ptr += 1;
|
ptr += 1;
|
||||||
}
|
}
|
||||||
ptr -= 1; // to remove the trailing comma
|
/* to remove the trailing new-line */
|
||||||
|
ptr -= 1;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_constants.c,v $ */
|
/* $Source$ */
|
||||||
/* $Revision: $ */
|
/* $Revision$ */
|
||||||
/* $Date: $ */
|
/* $Date$ */
|
||||||
|
@ -256,21 +256,20 @@ int crypt_get_size(const char* namein, int *sizeout) {
|
|||||||
* written.
|
* written.
|
||||||
* a -1 return value signifies insufficient space made available
|
* a -1 return value signifies insufficient space made available
|
||||||
*/
|
*/
|
||||||
int crypt_list_all_sizes(char *names_list,
|
int crypt_list_all_sizes(char *names_list, unsigned long *names_list_size) {
|
||||||
unsigned long *names_list_size) {
|
|
||||||
int i;
|
int i;
|
||||||
unsigned long total_len = 0;
|
unsigned long total_len = 0;
|
||||||
char number[10];
|
char number[10];
|
||||||
int number_len;
|
int number_len;
|
||||||
int count = sizeof(_crypt_sizes) / sizeof(crypt_size);
|
int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
|
||||||
|
|
||||||
/* calculate amount of memory required for the list */
|
/* calculate amount of memory required for the list */
|
||||||
for (i=0; i<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
total_len += strlen(_crypt_sizes[i].name) + 1;
|
total_len += strlen(_crypt_sizes[i].name) + 1;
|
||||||
// the above +1 is for the commas
|
/* the above +1 is for the commas */
|
||||||
sprintf(number,"%lu",_crypt_sizes[i].size);
|
sprintf(number,"%lu",_crypt_sizes[i].size);
|
||||||
total_len += strlen(number) + 1;
|
total_len += strlen(number) + 1;
|
||||||
// this last +1 is for newlines (and ending NULL)
|
/* this last +1 is for newlines (and ending NULL) */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names_list == NULL) {
|
if (names_list == NULL) {
|
||||||
@ -293,13 +292,14 @@ int crypt_list_all_sizes(char *names_list,
|
|||||||
strcpy(ptr, "\n");
|
strcpy(ptr, "\n");
|
||||||
ptr += 1;
|
ptr += 1;
|
||||||
}
|
}
|
||||||
ptr -= 1; // to remove the trailing comma
|
/* to remove the trailing new-line */
|
||||||
|
ptr -= 1;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_sizes.c,v $ */
|
/* $Source$ */
|
||||||
/* $Revision: $ */
|
/* $Revision$ */
|
||||||
/* $Date: $ */
|
/* $Date$ */
|
||||||
|
Loading…
Reference in New Issue
Block a user