1160814Ssimon/****************************************************************************** 2160814Ssimon * 3160814Ssimon * Copyright 2000 4160814Ssimon * Broadcom Corporation 5160814Ssimon * 16215 Alton Parkway 6160814Ssimon * PO Box 57013 7160814Ssimon * Irvine CA 92619-7013 8160814Ssimon * 9160814Ssimon *****************************************************************************/ 10160814Ssimon/* 11160814Ssimon * Broadcom Corporation uBSec SDK 12160814Ssimon */ 13160814Ssimon/* 14160814Ssimon * Character device header file. 15160814Ssimon */ 16160814Ssimon/* 17160814Ssimon * Revision History: 18160814Ssimon * 19160814Ssimon * October 2000 JTT Created. 20160814Ssimon */ 21160814Ssimon 22160814Ssimon#define MAX_PUBLIC_KEY_BITS (1024) 23160814Ssimon#define MAX_PUBLIC_KEY_BYTES (1024/8) 24160814Ssimon#define SHA_BIT_SIZE (160) 25160814Ssimon#define MAX_CRYPTO_KEY_LENGTH 24 26160814Ssimon#define MAX_MAC_KEY_LENGTH 64 27160814Ssimon#define UBSEC_CRYPTO_DEVICE_NAME ((unsigned char *)"/dev/ubscrypt") 28160814Ssimon#define UBSEC_KEY_DEVICE_NAME ((unsigned char *)"/dev/ubskey") 29160814Ssimon 30160814Ssimon/* Math command types. */ 31160814Ssimon#define UBSEC_MATH_MODADD 0x0001 32160814Ssimon#define UBSEC_MATH_MODSUB 0x0002 33160814Ssimon#define UBSEC_MATH_MODMUL 0x0004 34160814Ssimon#define UBSEC_MATH_MODEXP 0x0008 35160814Ssimon#define UBSEC_MATH_MODREM 0x0010 36160814Ssimon#define UBSEC_MATH_MODINV 0x0020 37160814Ssimon 38160814Ssimontypedef long ubsec_MathCommand_t; 39160814Ssimontypedef long ubsec_RNGCommand_t; 40160814Ssimon 41160814Ssimontypedef struct ubsec_crypto_context_s { 42160814Ssimon unsigned int flags; 43160814Ssimon unsigned char crypto[MAX_CRYPTO_KEY_LENGTH]; 44160814Ssimon unsigned char auth[MAX_MAC_KEY_LENGTH]; 45160814Ssimon} ubsec_crypto_context_t, *ubsec_crypto_context_p; 46160814Ssimon 47160814Ssimon/* 48160814Ssimon * Predeclare the function pointer types that we dynamically load from the DSO. 49160814Ssimon */ 50160814Ssimon 51160814Ssimontypedef int t_UBSEC_ubsec_bytes_to_bits(unsigned char *n, int bytes); 52160814Ssimon 53160814Ssimontypedef int t_UBSEC_ubsec_bits_to_bytes(int bits); 54160814Ssimon 55160814Ssimontypedef int t_UBSEC_ubsec_open(unsigned char *device); 56160814Ssimon 57160814Ssimontypedef int t_UBSEC_ubsec_close(int fd); 58160814Ssimon 59160814Ssimontypedef int t_UBSEC_diffie_hellman_generate_ioctl (int fd, 60160814Ssimon unsigned char *x, int *x_len, unsigned char *y, int *y_len, 61160814Ssimon unsigned char *g, int g_len, unsigned char *m, int m_len, 62160814Ssimon unsigned char *userX, int userX_len, int random_bits); 63160814Ssimon 64160814Ssimontypedef int t_UBSEC_diffie_hellman_agree_ioctl (int fd, 65160814Ssimon unsigned char *x, int x_len, unsigned char *y, int y_len, 66160814Ssimon unsigned char *m, int m_len, unsigned char *k, int *k_len); 67160814Ssimon 68160814Ssimontypedef int t_UBSEC_rsa_mod_exp_ioctl (int fd, 69160814Ssimon unsigned char *x, int x_len, unsigned char *m, int m_len, 70160814Ssimon unsigned char *e, int e_len, unsigned char *y, int *y_len); 71160814Ssimon 72160814Ssimontypedef int t_UBSEC_rsa_mod_exp_crt_ioctl (int fd, 73160814Ssimon unsigned char *x, int x_len, unsigned char *qinv, int qinv_len, 74160814Ssimon unsigned char *edq, int edq_len, unsigned char *q, int q_len, 75160814Ssimon unsigned char *edp, int edp_len, unsigned char *p, int p_len, 76160814Ssimon unsigned char *y, int *y_len); 77160814Ssimon 78160814Ssimontypedef int t_UBSEC_dsa_sign_ioctl (int fd, 79160814Ssimon int hash, unsigned char *data, int data_len, 80160814Ssimon unsigned char *rndom, int random_len, 81160814Ssimon unsigned char *p, int p_len, unsigned char *q, int q_len, 82160814Ssimon unsigned char *g, int g_len, unsigned char *key, int key_len, 83160814Ssimon unsigned char *r, int *r_len, unsigned char *s, int *s_len); 84160814Ssimon 85160814Ssimontypedef int t_UBSEC_dsa_verify_ioctl (int fd, 86160814Ssimon int hash, unsigned char *data, int data_len, 87160814Ssimon unsigned char *p, int p_len, unsigned char *q, int q_len, 88160814Ssimon unsigned char *g, int g_len, unsigned char *key, int key_len, 89160814Ssimon unsigned char *r, int r_len, unsigned char *s, int s_len, 90160814Ssimon unsigned char *v, int *v_len); 91160814Ssimon 92160814Ssimontypedef int t_UBSEC_math_accelerate_ioctl(int fd, ubsec_MathCommand_t command, 93160814Ssimon unsigned char *ModN, int *ModN_len, unsigned char *ExpE, int *ExpE_len, 94160814Ssimon unsigned char *ParamA, int *ParamA_len, unsigned char *ParamB, int *ParamB_len, 95160814Ssimon unsigned char *Result, int *Result_len); 96160814Ssimon 97160814Ssimontypedef int t_UBSEC_rng_ioctl(int fd, ubsec_RNGCommand_t command, 98160814Ssimon unsigned char *Result, int *Result_len); 99160814Ssimon 100160814Ssimontypedef int t_UBSEC_max_key_len_ioctl(int fd, int *max_key_len); 101