56 if (
line->buf==NULL) {
65 if (
line->vldsz>0)
break;
132 memset(
buf.buf, 0,
buf.bufsz);
158 else if (!strcmp(
"OK", (
const char*)ans.
buf)) {
161 else if (!strcmp(
"ERR", (
const char*)ans.
buf)) {
163 nn = (eno.
buf!=NULL) ? atoi((
const char*)eno.
buf) : 0;
201 if (key!=NULL && cipher!=NULL) {
230 if (!strcmp(
"END", (
const char*)
line.buf)) {
260 if (algor==NULL)
return ret;
272 if (ret.
buf==NULL)
return ret;
284 if (ret.
buf==NULL || ret.
vldsz<=0) {
367 int cryptf =
FALSE, sock, cc, ret = 0, tm = 10;
375 EVP_CIPHER* cipher = NULL;
396 if (keyex!=0 && cryptm!=0) {
420 if (!cryptf) chmode =
ON;
456 if (salt.
buf==NULL) {
472 memset(pass, 0, strlen(pass));
479 memset(
buf.buf, 0,
buf.bufsz);
498 memset(
buf.buf, 0,
buf.bufsz);
503 if (shdkey.
buf!=NULL) {
504 memset(shdkey.
buf, 0, shdkey.
bufsz);
544 char* crypt_cmd = NULL;
546 JBXL_DH* dhkey = NULL;
552 if (cryptm==SSL_AES128CBC) crypt_cmd = (
char*)
"CRYPT AES128CBC";
553 else if (cryptm==SSL_3DES3CBC) crypt_cmd = (
char*)
"CRYPT 3DES3CBC";
558 if (spki.
buf==NULL) {
559 PRINT_MESG(
"ERROR: start_CRYPT_transfer: spki is NULL (%d)\n", spki.
state);
565 if (cfn!=NULL && ipaddr.
buf!=NULL) {
573 mpki = gen_DHspki_fs(spki, &dhkey);
574 if (dhkey==NULL || mpki.
buf==NULL || mpki.
vldsz<=0) {
575 PRINT_MESG(
"ERROR: start_CRYPT_transfer: cannot generate DH key\n");
576 ERR_print_errors_fp(stderr);
577 if (dhkey!=NULL) JBXL_DH_free(dhkey);
585 #ifdef ISNET_LEGACY_KEY
588 int sz = JBXL_DH_size(dhkey);
589 if (shdkey->
buf!=NULL) memset(shdkey->
buf, 0, shdkey->
bufsz);
598 if (!cc || shdkey->
buf==NULL || shdkey->
vldsz<SSL_IV_SIZE) {
599 PRINT_MESG(
"ERROR: start_CRYPT_transfer: cannot generate shared key\n");
600 ERR_print_errors_fp(stderr);
620 memset(shdkey->
buf, 0, shdkey->
bufsz);
Buffer encode_base64_Buffer(Buffer buf)
バイナリデータ buf.bufの buf.vldszバイトを Base64にエンコード する
Buffer get_line_Buffer(Buffer str, int n)
複数行の文字列バッファから任意の行を取り出す.
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
void chomp_Buffer(Buffer *str)
最初の改行コード以降を無視する.
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する.
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
#define make_Buffer_bystr(str)
set_Buffer()
void line(WSGraph vp, int x1, int y1, int x2, int y2, int cc)
Buffer get_operand(Buffer msg)
Buffer get_command(Buffer msg)
void reset_isnet_client_stream(void)
static mstream ISNET_Client_Stream
int start_CRYPT_transfer(int sock, int keyex, int cryptm, Buffer ipaddr, char *cfn, int tm, Buffer *shdkey, EVP_CIPHER **cipher)
int send_spki_recv_ans(int sock, Buffer mkey, int tm, Buffer *key, EVP_CIPHER *cipher)
int check_auth(Buffer ahost, int aport, Buffer userid, Buffer passwd, int chmode, int keyex, int cryptm, char *cfn, int cont)
Buffer send_algor_recv_spki(int sock, char *algor, int tm, Buffer *key, EVP_CIPHER *cipher)
static Buffer isnet_plain_line(Buffer line, Buffer *key, EVP_CIPHER *cipher)
static int ISNET_Client_Sock
static int isnet_recv_line(int sock, Buffer *line, int tm)
int stop_CRYPT_transfer(int sock, int tm, Buffer *shdkey, EVP_CIPHER *cipher)
int send_command_recv_ans(int sock, char *command, int tm, Buffer *key, EVP_CIPHER *cipher)
Buffer recv_mesg_until_end(int sock, int tm, Buffer *key, EVP_CIPHER *cipher)
#define JBXL_ISNET_CMNKEYALG_ERROR
知らない共通鍵暗号アルゴリズム
#define JBXL_ARGS_ERROR
不正な引数(NULLなど)
#define JBXL_ISNET_PUBKEYALG_ERROR
知らない公開鍵暗号アルゴリズム
#define JBXL_NET_SEND_ERROR
データの送信エラー
#define JBXL_ISNET_CONNECT_ERROR
認証サーバとの接続エラー
#define JBXL_ISNET_SERVER_ERROR
認証ホストの検証エラー
#define JBXL_ISNET_NULLANS_ERROR
サーバからの返答が NULL
#define JBXL_ISNET_CMD_ERROR
サーバから 'OK', 'ERR' 以外のものを受信した
#define JBXL_ISNET_START_ERROR
認証サーバとの通信開始エラー(相手は認証サーバでない?)
#define JBXL_ISNET_SPKI_ERROR
SPKIのエラー(ISNET内)
#define JBXL_ISNET_PASSWD_ERROR
ユーザ認証失敗(ユーザは存在するが,パスワードが一致しない)
#define JBXL_ISNET_DHKEY_ERROR
DH鍵エラー(ISNET内)
#define JBXL_ISNET_USER_ERROR
ユーザ認証失敗(ユーザが存在しない)
#define JBXL_NET_RECV_ERROR
データの受信エラー
#define JBXL_MALLOC_ERROR
メモリ確保エラー
#define JBXL_ISNET_CHALLENGE_ERROR
チャレンジキー合意エラー
int socket_close(int sofd)
call shutdown(), close()
char * get_ipaddr_byname(const char *hostname, int family)
ホスト名 → IPv4/IPv6 アドレス(文字列)
#define tcp_client_socket(h, p)
char * x2crypt(char *pass, char *bsalt)
int bufsz
確保してあるバッファの大きさ - 1.
int vldsz
データの長さ.バイナリデータの場合も使用可能.文字列の場合は 0x00 を含まない.
int state
変数の状態を表す.正常は JBXL_NORMAL
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.