Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(SS_CRYPTO_SOURCE
aead.c
stream.c
base64.c
plain.c
)

set(SS_PLUGIN_SOURCE
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ crypto_src = crypto.c \
aead.c \
stream.c \
ppbloom.c \
base64.c
base64.c \
plain.c

plugin_src = plugin.c

Expand Down
16 changes: 16 additions & 0 deletions src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "crypto.h"
#include "stream.h"
#include "aead.h"
#include "plain.h"
#include "utils.h"
#include "ppbloom.h"

Expand Down Expand Up @@ -144,6 +145,21 @@ crypto_init(const char *password, const char *key, const char *method)
#endif

if (method != NULL) {
if (strcmp(method, "plain") == 0) {
crypto_t *crypto = (crypto_t *)malloc(sizeof(crypto_t));
crypto_t tmp = {
.cipher = NULL,
.encrypt_all = &plain_stream_do_all,
.decrypt_all = &plain_stream_do_all,
.encrypt = &plain_stream_do,
.decrypt = &plain_stream_do,
.ctx_init = &plain_stream_ctx_init,
.ctx_release = &plain_stream_ctx_release,
};
memcpy(crypto, &tmp, sizeof(crypto_t));
return crypto;
}

for (i = 0; i < STREAM_CIPHER_NUM; i++)
if (strcmp(method, supported_stream_ciphers[i]) == 0) {
m = i;
Expand Down
33 changes: 33 additions & 0 deletions src/plain.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "plain.h"

int
plain_stream_do_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity)
{
(void)plaintext; (void)cipher; (void)capacity;

return CRYPTO_OK;
}

int
plain_stream_do(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
{
(void)ciphertext; (void)cipher_ctx; (void)capacity;

return CRYPTO_OK;
}

void
plain_stream_ctx_init(cipher_t *cipher, cipher_ctx_t *cipher_ctx, int enc)
{
(void)cipher; (void)cipher_ctx; (void)enc;
}

void
plain_stream_ctx_release(cipher_ctx_t *cipher_ctx)
{
(void)cipher_ctx;
}
12 changes: 12 additions & 0 deletions src/plain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _PLAIN_H
#define _PLAIN_H

#include "crypto.h"

int plain_stream_do_all(buffer_t *, cipher_t *, size_t);
int plain_stream_do(buffer_t *, cipher_ctx_t *, size_t);

void plain_stream_ctx_init(cipher_t *, cipher_ctx_t *, int);
void plain_stream_ctx_release(cipher_ctx_t *);

#endif // _PLAIN_H
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ main(int argc, char **argv)
}

if (server_num == 0 || server_port == NULL
|| (password == NULL && key == NULL)) {
|| (strcmp(method, "plain") && password == NULL && key == NULL)) {
usage();
exit(EXIT_FAILURE);
}
Expand Down