93    if (spki.
buf==NULL || shdkey==NULL)  
return FALSE;
 
   97        *shdkey = get_DHsharedkey(spki, dhkey);     
 
   99    else if (keyex==SSL_RSA) {                      
 
 
  119    if (key!=NULL && cipher!=NULL) {
 
 
  143    if (key!=NULL && cipher!=NULL) {
 
 
  169    if (key!=NULL && cipher!=NULL) {
 
 
  193    if (key!=NULL && cipher!=NULL) {
 
 
  215    if (key!=NULL && cipher!=NULL) {
 
 
  239    if (key!=NULL && cipher!=NULL) {
 
 
  257    if (key==NULL || cipher==NULL) 
return buf;
 
 
  267    if (key==NULL || cipher==NULL) 
return buf;
 
 
  306    if (key!=NULL && cipher!=NULL) {
 
 
  359    if (key!=NULL && cipher!=NULL) {
 
 
  397    if (key==NULL || cipher==NULL) 
return buf;
 
 
  429    if (key==NULL || cipher==NULL) 
return buf;
 
 
  460    if (key==NULL || cipher==NULL) 
return buf;
 
 
  491    if (key==NULL || cipher==NULL) 
return buf;
 
 
  531    fp = fopen(filename, 
"rb");
 
 
  573    if (fp==NULL) 
return FALSE;
 
 
  601    if (ipa.
buf==NULL) 
return pki;
 
 
  647    EVP_CIPHER* cipher = NULL;
 
  649    if (type==SSL_AES128CBC) {
 
  650        cipher = (EVP_CIPHER*)EVP_aes_128_cbc();
 
  652    else if (type==SSL_3DES3CBC) {
 
  653        cipher = (EVP_CIPHER*)EVP_des_ede3_cbc();
 
 
  678    if (shdkey.
buf==NULL || cipher==NULL) 
return dec;
 
  680    iv  = (
unsigned char*)&(shdkey.
buf[shdkey.
vldsz - SSL_IV_SIZE]);
 
  682#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  683    ctx = (EVP_CIPHER_CTX*)malloc(
sizeof(EVP_CIPHER_CTX));  
 
  684    memset(ctx, 0, 
sizeof(EVP_CIPHER_CTX));
 
  685    EVP_CIPHER_CTX_init(ctx);
 
  687    ctx = EVP_CIPHER_CTX_new();                             
 
  688    EVP_CIPHER_CTX_reset(ctx);
 
  691    EVP_DecryptInit_ex(ctx, cipher, NULL, shdkey.
buf, iv);
 
  693    dec = 
make_Buffer(
buf.vldsz + EVP_CIPHER_CTX_block_size(ctx) + 1);
 
  694    if (dec.
buf==NULL) 
return dec;
 
  696    EVP_DecryptUpdate(ctx, dec.
buf, &sz, 
buf.buf, 
buf.vldsz);
 
  697    EVP_DecryptFinal_ex(ctx, &(dec.
buf[sz]), &ss);
 
  701#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  702    EVP_CIPHER_CTX_cleanup(ctx);
 
 
  724    int  i, 
len, ss=0, sz;
 
  731    if (shdkey.
buf==NULL || cipher==NULL) 
return enc;
 
  733    iv  = (
unsigned char*)&(shdkey.
buf[shdkey.
vldsz - SSL_IV_SIZE]);
 
  735#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  736    ctx = (EVP_CIPHER_CTX*)malloc(
sizeof(EVP_CIPHER_CTX));  
 
  737    memset(ctx, 0, 
sizeof(EVP_CIPHER_CTX));
 
  738    EVP_CIPHER_CTX_init(ctx);
 
  740    ctx = EVP_CIPHER_CTX_new();                             
 
  741    EVP_CIPHER_CTX_reset(ctx);
 
  744    EVP_EncryptInit_ex(ctx, cipher, NULL, shdkey.
buf, iv);
 
  748    if (enc.
buf==NULL) 
return enc;
 
  750    for (i=0; i<
len/SSL_ENC_BLCKSZ; i++) {
 
  751        EVP_EncryptUpdate(ctx, &(enc.
buf[ss]), &sz, &(
buf.buf[i*SSL_ENC_BLCKSZ]), SSL_ENC_BLCKSZ);
 
  754    if (
len%SSL_ENC_BLCKSZ!=0) {
 
  755        EVP_EncryptUpdate(ctx, &(enc.
buf[ss]), &sz, &(
buf.buf[i*SSL_ENC_BLCKSZ]), 
len%SSL_ENC_BLCKSZ);
 
  758    EVP_EncryptFinal_ex(ctx, &(enc.
buf[ss]), &sz);
 
  761#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  762    EVP_CIPHER_CTX_cleanup(ctx);
 
 
  775    if (p_cipher==NULL || *p_cipher==NULL) 
return;
 
 
  809    SSL_load_error_strings();
 
 
  830#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  831    ssl_ctx = SSL_CTX_new(SSLv23_client_method());
 
  833    ssl_ctx = SSL_CTX_new(TLS_client_method());
 
  835    if (ssl_ctx==NULL) 
return NULL;
 
  838    if (ca!=NULL) SSL_CTX_load_verify_locations(ssl_ctx, ca, NULL);
 
 
  863    if (ssl_ctx==NULL) 
return NULL;
 
  865    SSL* ssl = SSL_new(ssl_ctx);
 
  871    int ret = SSL_set_fd(ssl, sock);
 
  878    ret = SSL_connect(ssl);
 
  886        long lrt = SSL_get_verify_result(ssl);
 
  887        if (lrt!=X509_V_OK) {
 
 
  918#if OPENSSL_VERSION_NUMBER < 0x10101000L 
  919    ssl_ctx = SSL_CTX_new(SSLv23_server_method());
 
  921    ssl_ctx = SSL_CTX_new(TLS_server_method());
 
  923    if (ssl_ctx==NULL) 
return NULL;
 
  926    if (crt_fn!=NULL && key_fn!=NULL) {
 
  928            ret = SSL_CTX_use_certificate_file(ssl_ctx, crt_fn, SSL_FILETYPE_PEM);
 
  935            ret = SSL_CTX_use_PrivateKey_file(ssl_ctx, key_fn, SSL_FILETYPE_PEM);
 
  938        if (ret==1 && chn_fn!=NULL) {
 
  943            SSL_CTX_free(ssl_ctx);
 
 
  968    if (file==NULL) 
return ret;
 
  970    BIO* bio = BIO_new(BIO_s_file());
 
  971    if (bio==NULL) 
return ret;
 
  973    BIO_read_filename(bio, file);
 
  974    X509* x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
 
  976        ret = SSL_CTX_add_extra_chain_cert(ssl_ctx, x509);
 
  977        x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
 
 
  998    if (file==NULL) 
return ret;
 
 1003    bio = BIO_new(BIO_s_file());
 
 1004    if (bio==NULL) 
return ret;
 
 1005    BIO_read_filename(bio, file);
 
 1008    x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
 
 1010        ret = SSL_CTX_use_certificate(ssl_ctx, x509);
 
 1014        x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
 
 1016            ret = SSL_CTX_add_extra_chain_cert(ssl_ctx, x509);
 
 1017            x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
 
 
 1027#define  SSL_ACCEPT_COUNT_MAX  10 
 1044    if (ssl_ctx==NULL) 
return NULL;
 
 1047    SSL* ssl = SSL_new(ssl_ctx);
 
 1053    int ret = SSL_set_fd(ssl, sock);
 
 1060    SSL_set_accept_state(ssl);
 
 1062        ret = SSL_accept(ssl);
 
 1063        ret = SSL_get_error(ssl, ret);
 
 1065    } 
while (cnt<=cnt_max && (ret==SSL_ERROR_WANT_READ || ret==SSL_ERROR_WANT_WRITE || ret==SSL_ERROR_SYSCALL));
 
 1067    if (ret==SSL_ERROR_SSL || cnt>cnt_max) {
 
 
 1113    pp = (
char*)SSL_get_cipher(ssl);
 
 1116    pp = (
char*)SSL_get_cipher_version(ssl);
 
 1119    x509 = SSL_get_peer_certificate(ssl); 
 
 1120    if (x509==NULL) 
return lt;
 
 1122    bio = BIO_new(BIO_s_mem());
 
 1128    X509_NAME_print_ex(bio, X509_get_subject_name(x509), 0, XN_FLAG_RFC2253);
 
 1132    X509_NAME_print_ex(bio, X509_get_issuer_name(x509), 0, XN_FLAG_RFC2253);
 
 1136    ASN1_TIME_print(bio, X509_get_notBefore(x509));
 
 1140    ASN1_TIME_print(bio, X509_get_notAfter(x509));
 
 
 1177    memset(rmsg, 0, size);
 
 1178    cc = SSL_read(ssl, rmsg, size-1);
 
 
 1208    if (size<=0) size = strlen(smsg);
 
 1209    cc = SSL_write(ssl, smsg, size);
 
 
 1278    sz = strlen(mesg) + 3;    
 
 1279    buf = (
char*)malloc(sz);
 
 1282    strncpy(
buf, mesg, sz);
 
 1283    strncat(
buf, 
"\r\n", 2);
 
 
 1333    if (sb->buf==NULL) {
 
 1338    while (sb->datano==0) {
 
 1340        if (cc<=0) 
return cc;
 
 1347    if (strlen((
const char*)pp)>=(
unsigned int)sz) {
 
 1348        memcpy(mesg, pp, sz-1);
 
 1352    memcpy(mesg, pp, strlen((
const char*)pp));
 
 1355    return strlen(mesg);
 
 
 1386    cc = SSL_read(ssl, str->
buf, str->
bufsz-1);
 
 1387    if (cc>=0) str->
vldsz = cc;
 
 
 1412    if (str->
vldsz<0) str->
vldsz = strlen((
const char*)str->
buf);
 
 1413    cc = SSL_write(ssl, str->
buf, str->
vldsz);
 
 
 1449    if (cc>=0) str->
vldsz = cc;
 
 
 1473    cc = SSL_write(ssl, str->
buf, strlen((
const char*)str->
buf));
 
 
 1501    cc = SSL_write(ssl, 
buf.buf, strlen((
const char*)
buf.buf));
 
 
 1548    if (sb->buf==NULL) {
 
 1553    while (sb->datano==0) {
 
 
 1648    memset(rmsg, 0, size);
 
 1650    if (ssl!=NULL) cc = SSL_read(ssl, rmsg, size-1);
 
 1651    else           cc = recv(sock, rmsg, size-1, 0);
 
 
 1682    if (size<=0) size = strlen(smsg);
 
 1683    if (ssl!=NULL) cc = SSL_write(ssl, smsg, size);
 
 1684    else           cc = send(sock, smsg, size, 0);
 
 
 1754    sz = strlen(mesg) + 3;    
 
 1755    buf = (
char*)malloc(sz);
 
 1758    strncpy(
buf, mesg, sz);
 
 1759    strncat(
buf, 
"\r\n", 2);
 
 
 1809    if (sb->buf==NULL) {
 
 1814    while (sb->datano==0) {
 
 1816        if (cc<=0) 
return cc;
 
 1823    if (strlen((
const char*)pp)>=(
unsigned int)sz) {
 
 1824        memcpy(mesg, pp, sz-1);
 
 1828    memcpy(mesg, pp, strlen((
const char*)pp));
 
 1831    return strlen(mesg);
 
 
 1859    if (ssl!=NULL) cc = SSL_read(ssl, str->
buf, str->
bufsz-1);
 
 1860    else           cc = recv(sock, str->
buf, str->
bufsz-1, 0);
 
 1862    if (cc>=0) str->
vldsz = cc;
 
 
 1887    if (str->
vldsz<0) str->
vldsz = strlen((
const char*)str->
buf);
 
 1889        cc = SSL_write(ssl, str->
buf, str->
vldsz);
 
 1892        cc = send(sock, str->
buf, str->
vldsz, 0);
 
 
 1928    if (cc>=0) str->
vldsz = cc;
 
 
 1957    if (mod!=NULL && mod->
buf!=NULL) modon = 
TRUE;
 
 1959    if (modon) memset(mod->
buf, 0, mod->
vldsz);
 
 1976    if (sz>size && modon) {
 
 
 2012    if (mod!=NULL && mod->
buf!=NULL) modon = 
TRUE;
 
 2014    if (modon) memset(mod->
buf, 0, mod->
vldsz);
 
 2031    if (sz>size && modon) {
 
 
 2058    if (ssl!=NULL) cc = SSL_write(ssl, str->
buf, strlen((
const char*)str->
buf));
 
 2059    else           cc = send(sock, str->
buf, strlen((
const char*)str->
buf), 0);
 
 
 2089    if (ssl!=NULL) cc = SSL_write(ssl, 
buf.buf, strlen((
const char*)
buf.buf));
 
 2090    else           cc = send(sock, 
buf.buf, strlen((
const char*)
buf.buf), 0);
 
 
 2136    if (sb->buf==NULL) {
 
 2141    while (sb->datano==0) {
 
 
Buffer encode_base64_Buffer(Buffer buf)
バイナリデータ buf.bufの buf.vldszバイトを Base64にエンコード する
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
void clear_Buffer(Buffer *str)
Buffer型変数 のバッファ部を 0クリアする.
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
Buffer init_Buffer()
初期化したBuffer型変数を返す.
Buffer dup_Buffer(Buffer buf)
Buffer型変数のコピーをつくる.
Buffer decode_base64_Buffer(Buffer str)
strのバッファを Base64からデコードする
int cat_Buffer(Buffer *src, Buffer *dst)
Buffer変数 srcから dstへバッファを catする.
int copy_Buffer(Buffer *src, Buffer *dst)
Buffer型変数 srcから dstへバッファをコピーする.
int copy_b2Buffer(void *src, Buffer *dst, int len)
任意のバイナリデータsrcを Buffer型変数dstへ lenバイト copyする
#define copy_s2Buffer(src, dst)
copy_b2Buffer()
#define bincmp_Buffer(a, b)
cmp_Buffer()
#define strcmp_Buffer(a, b)
cmp_Buffer()
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
#define make_Buffer_bystr(str)
set_Buffer()
#define JBXL_ARGS_ERROR
不正な引数(NULLなど)
#define JBXL_SSL_RECV_ERROR
SSL 受信エラー
#define JBXL_NET_BUFSZ_ERROR
受信バッファの長さが足りない.はみ出したデータは捨てられた
#define JBXL_SSL_SEND_ERROR
SSL 送信エラー
#define JBXL_MALLOC_ERROR
メモリ確保エラー
#define JBXL_NET_BUF_ERROR
受信バッファにデータは存在するはずだが,原因不明の理由により獲得に失敗した
#define JBXL_NET_RECV_TIMEOUT
受信タイムアウト
int recv_wait(int sock, int tm)
#define tcp_send_mesg(s, m)
int bufsz
確保してあるバッファの大きさ - 1.
int vldsz
データの長さ.バイナリデータの場合も使用可能.文字列の場合は 0x00 を含まない.
int state
変数の状態を表す.正常は JBXL_NORMAL
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
#define add_tList_node_str(p, k, v)
add_tList_node_bystr()