

#include <nitroWiFi/cps.h>
typedef struct _CPSSslConnection {
CPSSslSession *session; // the session this connection belongs to
u8 reuse_session; // non 0 if session should be reused
u8 padding;
u16 method; // cipher suite
u8 client_random[32];
u8 server_random[32];
u8 key_block[2*(20+16+0)];
u8 *send_mac; // points to somewhere in key_block[]
u8 *send_key; // ditto
u8 *send_iv; // ditto
CPSCipherCtx send_cipher; // cipher context for send
u8 send_seq[8]; // 64 bit sequence
u8 *rcv_mac; // points to somewhere in key_block[]
u8 *rcv_key; // ditto
u8 *rcv_iv; // ditto
CPSCipherCtx rcv_cipher; // cipher context for receive
u8 rcv_seq[8]; // 64 bit sequence
CPSSha1Ctx sha1_hash; // hash of handshake messages in SHA1
CPSSha1Ctx sha1_hash_tmp;
CPSMd5Ctx md5_hash; // hash of handshake messages in MD5
CPSMd5Ctx md5_hash_tmp;
u8 server; // non 0 if server type connection
u8 state;
u16 padding2;
//
// certificate
//
int sig_algorithm; // signature algorithm
int pub_algorithm; // public key algorithm
u8 *hash_start; // start address of hash area
u8 *hash_end; // end address of hash area + 1
u8 hash_val[20]; // hash value of hash_start..hash_end
int hash_len; // valid length of hash_val[]
CPSCaInfo midca_info; // middle ca info
u8 modulus[CPS_MAX_RSA_LEN]; // modulus
u32 modulus_len; // length of modulus in bytes
u8 exponent[CPS_MAX_RSA_PUBLICEXPONENT_LEN];
// public exponent
int exponent_len; // length of exponent in bytes
u8 *signature;
int signature_len;
u8 seen_validity; // next string is 'subject', not 'issuer'
u8 seen_pub_algorithm; // next BIT STRING is public key information
u8 seen_attr;
u8 date_ok;
char issuer[CPS_MAX_DN_LEN + 1];
char subject[CPS_MAX_DN_LEN + 1];
char cn[CPS_MAX_CN_LEN + 1];
char *server_name; // server name to match
u8 *cert; // for auth_callback
int certlen;
u32 cur_date; // 65536*year + 256*month + day
int (*auth_callback)(int, struct _CPSSslConnection *, int);
CPSCaInfo **ca_info;
int ca_builtins;
CPSPrivateKey *my_key;
CPSCertificate *my_certificate;
//
// ssl_read()
//
u8 *inbuf; // pointer to input buffer (NULL if none)
long inbuf_len; // length of inbuf
long inbuf_pnt; // index of current position (0..inbuf_len-1)
} CPSSslConnection;
SSLコネクションを定義する構造体です。
CPSSoc内のフィールドからポイントされます。
殆どのフィールドはシステムが設定します。アプリケーションが設定しなければならないフィールドは以下の通り。
| server_name | NULLでない場合、証明書のサーバ名(Common Name)との比較が行われ、その結果がコールバック関数に渡されます。 証明書のサーバ名としてのワイルドカードをサポートしています。 |
| auth_callback | 証明書の認証作業が終わる度に呼び出されます。最初のパラメータとしてエラーコードが、二番目のパラメータとしてCPSSslConnectionへのポインタが、三つ目のパラメータとして認証チェーン内の段数(初期値は0)が渡されます。 渡されたエラーコードを変更して返すことによってエラーを無視することが出来ます。0以外を返すと認証は失敗します。 |
auth_callbackに渡されるCPSSslConnection *から、以下のフィールドを参照することが出来ます。
| cert certlen |
現在認証作業中の証明書へのポインタ、長さ。この証明書を元にしてCPSCaInfoを作りルート証明に追加することが出来ます。 |
| subject | 証明書のsubject。 |
| issuer | 証明書のissuer。 |
Ver. 2005/10/24 初版