Another night's work - move to ECDH + AES256 from RSA pubkey

This commit is contained in:
Nick Thomas
2013-08-08 00:48:02 +01:00
parent c77557b6ee
commit 118b7b8125
10 changed files with 364 additions and 148 deletions

View File

@@ -1,5 +1,4 @@
#include "util.h"
#include "rlocs.h"
#include <unistd.h>
#include <sys/types.h>
@@ -187,4 +186,22 @@ void session_teardown( struct session *session )
if ( session->output_if >= 0 && !session->same_if ) {
close( session->output_if );
}
}
// TODO: we can speed this one up, if necessary, by re-using the context.
// TODO: some error-checking
int sha256sum( unsigned char *src, size_t src_len, unsigned char dst[SHA256_DIGEST_LENGTH] )
{
unsigned int size = SHA256_DIGEST_LENGTH;
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
EVP_DigestInit_ex( ctx, EVP_sha256(), NULL );
EVP_DigestUpdate( ctx, src, src_len );
EVP_DigestFinal_ex( ctx, &dst[0], &size );
EVP_MD_CTX_destroy( ctx );
return size == SHA256_DIGEST_LENGTH;
}