dcrypt-gnutls.c revision c5e46dba179864f6f1adf196d46e7a0371b11914
/* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "randgen.h"
#include "array.h"
#include "hash-method.h"
#include "pkcs5.h"
#include "module-dir.h"
#include <gnutls/abstract.h>
#include "dcrypt.h"
#include "dcrypt-private.h"
struct dcrypt_context_symmetric {
enum dcrypt_sym_mode mode;
};
struct dcrypt_context_hmac {
};
struct dcrypt_public_key {
void *ctx;
};
struct dcrypt_private_key {
void *ctx;
};
static
int dcrypt_gnutls_private_to_public_key(struct dcrypt_private_key *priv_key, struct dcrypt_public_key **pub_key_r, const char **error_r);
static
{
}
return -1;
}
static
int dcrypt_gnutls_ctx_sym_create(const char *algorithm, enum dcrypt_sym_mode mode, struct dcrypt_context_symmetric **ctx_r, const char **error_r)
{
return 0;
}
static
{
pool_unref(&pool);
return 0;
}
static
void dcrypt_gnutls_ctx_sym_set_key(struct dcrypt_context_symmetric *ctx, const unsigned char *key, size_t key_len)
{
}
static
void dcrypt_gnutls_ctx_sym_set_iv(struct dcrypt_context_symmetric *ctx, const unsigned char *iv, size_t iv_len)
{
}
static
{
}
static
{
return 0;
}
static
{
return 0;
}
static
{
}
static
{
}
static
{
}
static
{
int ec;
return 0;
}
static
int dcrypt_gnutls_ctx_sym_update(struct dcrypt_context_symmetric *ctx, const unsigned char *data, size_t data_len, buffer_t *result, const char **error_r)
{
int ec;
return ec;
}
static
int dcrypt_gnutls_ctx_sym_final(struct dcrypt_context_symmetric *ctx, buffer_t *result, const char **error_r)
{
}
static
int dcrypt_gnutls_ctx_hmac_create(const char *algorithm, struct dcrypt_context_hmac **ctx_r, const char **error_r)
{
return 0;
}
static
{
pool_unref(&pool);
return 0;
}
static
void dcrypt_gnutls_ctx_hmac_set_key(struct dcrypt_context_hmac *ctx, const unsigned char *key, size_t key_len)
{
}
static
{
return 0;
}
static
{
int ec;
return 0;
}
static
int dcrypt_gnutls_ctx_hmac_update(struct dcrypt_context_hmac *ctx, const unsigned char *data, size_t data_len, const char **error_r)
{
int ec;
return 0;
}
static
int dcrypt_gnutls_ctx_hmac_final(struct dcrypt_context_hmac *ctx, buffer_t *result, const char **error_r)
{
return 0;
}
static
int dcrypt_gnutls_ecdh_derive_secret(struct dcrypt_public_key *peer_key, buffer_t *R, buffer_t *S, const char **error_r)
{
}
static
int dcrypt_gnutls_pbkdf2(const unsigned char *password, size_t password_len, const unsigned char *salt, size_t salt_len, const char *algorithm,
{
unsigned char buf[result_len];
/* only sha1 or sha256 is supported */
struct hmac_sha512_ctx ctx;
} else {
*error_r = "Unsupported algorithm";
return -1;
}
return 0;
}
static
int dcrypt_gnutls_generate_keypair(struct dcrypt_keypair *pair_r, enum dcrypt_key_type kind, unsigned int bits, const char *curve, const char **error_r)
{
if (kind == DCRYPT_KEY_EC) {
if (pk_curve == GNUTLS_ECC_CURVE_INVALID) {
*error_r = "Invalid curve";
return -1;
}
#if GNUTLS_VERSION_NUMBER >= 0x030500
#else
#endif
} else if (kind == DCRYPT_KEY_RSA) {
} else {
*error_r = "Unsupported key type";
return -1;
}
int ec;
#if GNUTLS_VERSION_NUMBER >= 0x030500
#endif
if (ec != GNUTLS_E_SUCCESS) {
}
}
static
int dcrypt_gnutls_load_private_key(struct dcrypt_private_key **key_r, const unsigned char *data, size_t data_len, dcrypt_password_cb *cb, void *ctx, const char **error_r)
{
}
static
int dcrypt_gnutls_load_public_key(struct dcrypt_public_key **key_r, const unsigned char *data, size_t data_len, const char **error_r)
{
}
static
int dcrypt_gnutls_store_private_key(struct dcrypt_private_key *key, const char *cipher, buffer_t *destination, dcrypt_password_cb *cb, void *ctx, const char **error_r)
{
/* then export PEM */
return 0;
}
static
int dcrypt_gnutls_store_public_key(struct dcrypt_public_key *key, buffer_t *destination, const char **error_r)
{
return 0;
}
static
int dcrypt_gnutls_private_to_public_key(struct dcrypt_private_key *priv_key, struct dcrypt_public_key **pub_key_r, const char **error_r)
{
int ec;
gnutls_datum_t m,e;
/* do not extract anything we don't need */
gnutls_free(m.data);
gnutls_free(e.data);
if (ec < 0) {
}
return 0;
gnutls_datum_t x,y,k;
gnutls_free(x.data);
gnutls_free(y.data);
if (ec < 0) {
}
return 0;
}
return -1;
}
static
{
}
static
{
}
static
{
}
static
int dcrypt_gnutls_rsa_encrypt(struct dcrypt_public_key *key, const unsigned char *data, size_t data_len, buffer_t *result, const char **error_r)
{
}
static
int dcrypt_gnutls_rsa_decrypt(struct dcrypt_private_key *key, const unsigned char *data, size_t data_len, buffer_t *result, const char **error_r)
{
}
static
int dcrypt_gnutls_oid_keytype(const unsigned char *oid, size_t oid_len, enum dcrypt_key_type *key_type, const char **error_r)
{
}
static
{
}
static
{
}
static
{
}
static struct dcrypt_vfs dcrypt_gnutls_vfs = {
// .ecdh_derive_secret = dcrypt_gnutls_ecdh_derive_secret,
};
{
}
void dcrypt_gnutls_deinit(void)
{
}