=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/digest.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- src/usr.bin/ssh/Attic/digest.c 2014/01/20 00:08:48 1.3 +++ src/usr.bin/ssh/Attic/digest.c 2014/01/27 18:58:14 1.4 @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.3 2014/01/20 00:08:48 djm Exp $ */ +/* $OpenBSD: digest.c,v 1.4 2014/01/27 18:58:14 markus Exp $ */ /* * Copyright (c) 2013 Damien Miller * @@ -66,6 +66,12 @@ return digest == NULL ? 0 : digest->digest_len; } +size_t +ssh_digest_blocksize(struct ssh_digest_ctx *ctx) +{ + return EVP_MD_CTX_block_size(&ctx->mdctx); +} + struct ssh_digest_ctx * ssh_digest_start(int alg) { @@ -84,6 +90,15 @@ } int +ssh_digest_copy_state(struct ssh_digest_ctx *from, struct ssh_digest_ctx *to) +{ + /* we have bcopy-style order while openssl has memcpy-style */ + if (!EVP_MD_CTX_copy_ex(&to->mdctx, &from->mdctx)) + return -1; + return 0; +} + +int ssh_digest_update(struct ssh_digest_ctx *ctx, const void *m, size_t mlen) { if (EVP_DigestUpdate(&ctx->mdctx, m, mlen) != 1) @@ -117,9 +132,11 @@ void ssh_digest_free(struct ssh_digest_ctx *ctx) { - EVP_MD_CTX_cleanup(&ctx->mdctx); - memset(ctx, 0, sizeof(*ctx)); - free(ctx); + if (ctx != NULL) { + EVP_MD_CTX_cleanup(&ctx->mdctx); + memset(ctx, 0, sizeof(*ctx)); + free(ctx); + } } int