diff options
author | Iru Cai <mytbk920423@gmail.com> | 2016-11-08 11:40:32 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2016-11-08 15:17:38 +0800 |
commit | 50d144a7305c6f454a8f8f1a10ac7234eac2ceeb (patch) | |
tree | 4a5ccf4b14bed75689d97b01de47b77d2819fdbb /src/protocol/internal/ssh_crypto_common.c | |
parent | 0a817b9fcb8e7a1bf5c4a910eb0de1a549b5ba9f (diff) | |
download | fqterm-50d144a7305c6f454a8f8f1a10ac7234eac2ceeb.tar.xz |
add aes-ctr cipher support
Diffstat (limited to 'src/protocol/internal/ssh_crypto_common.c')
-rw-r--r-- | src/protocol/internal/ssh_crypto_common.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/protocol/internal/ssh_crypto_common.c b/src/protocol/internal/ssh_crypto_common.c new file mode 100644 index 0000000..0c16d9d --- /dev/null +++ b/src/protocol/internal/ssh_crypto_common.c @@ -0,0 +1,39 @@ +#include "ssh_crypto_common.h" +#include <string.h> + +/* We need the first algorithm in the client side, + so search l first +*/ + +int +search_name(name_list l, const char *s) +{ + size_t ns = 1; + size_t i,j; + const char *p; + + if (*s=='\0') + return -1; + + for (p=s; *p; p++) { + if (*p==',') ns++; + } + const char *start[ns], *end[ns]; + + p = s; + for (i=0; i<ns; i++) { + start[i] = p; + end[i] = strchr(p, ','); + p = end[i]+1; + } + end[ns-1] = start[ns-1]+strlen(start[ns-1]); + + for (i=0; l[i].name!=NULL; i++) { + size_t len = strlen(l[i].name); + for (j=0; j<ns; j++) { + if (start[j]+len==end[j] && strncmp(start[j],l[i].name,len)==0) + return i; + } + } + return -1; +} |