aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-12 13:06:18 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-12 13:07:20 +0300
commit8c426cf0b4bbbdd05802fef61ff8483aeb01a4f9 (patch)
tree45b962804aa428953847d276b81c81b2c544bf02 /core
parent6007e90c661aca860a1a58e684c5c4fdbb3c4f55 (diff)
downloadaports-8c426cf0b4bbbdd05802fef61ff8483aeb01a4f9.tar.bz2
aports-8c426cf0b4bbbdd05802fef61ff8483aeb01a4f9.tar.xz
core/openssl: oneshot sha support for padlock
Heavily modified patch based on Michal Ludvig's work. Implements Padlock SHA support for oneshot hashing.
Diffstat (limited to 'core')
-rw-r--r--core/openssl/APKBUILD6
-rw-r--r--core/openssl/openssl-0.9.8k-padlock-oneshot-sha.patch605
2 files changed, 609 insertions, 2 deletions
diff --git a/core/openssl/APKBUILD b/core/openssl/APKBUILD
index 0ba7e4f1ee..a8a3d9151a 100644
--- a/core/openssl/APKBUILD
+++ b/core/openssl/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=openssl
pkgver=0.9.8k
-pkgrel=0
+pkgrel=1
pkgdesc="Toolkit for SSL v2/v3 and TLS v1"
url=http://openssl.org
depends=
@@ -14,6 +14,7 @@ source="http://www.openssl.org/source/${pkgname}-${pkgver}.tar.gz
http://www.linuxfromscratch.org/patches/downloads/openssl/openssl-0.9.8g-fix_manpages-1.patch
openssl-bb-basename.patch
openssl-0.9.8k-quote-cc.patch
+ openssl-0.9.8k-padlock-oneshot-sha.patch
"
build() {
@@ -32,4 +33,5 @@ build() {
md5sums="e555c6d58d276aec7fdc53363e338ab3 openssl-0.9.8k.tar.gz
04a6a88c2ee4badd4f8649792b73eaf3 openssl-0.9.8g-fix_manpages-1.patch
c6a9857a5dbd30cead0404aa7dd73977 openssl-bb-basename.patch
-c838eb8488896cfeb7de957a0cbe04ae openssl-0.9.8k-quote-cc.patch"
+c838eb8488896cfeb7de957a0cbe04ae openssl-0.9.8k-quote-cc.patch
+384560a86542afa6a805add96560f0c7 openssl-0.9.8k-padlock-oneshot-sha.patch"
diff --git a/core/openssl/openssl-0.9.8k-padlock-oneshot-sha.patch b/core/openssl/openssl-0.9.8k-padlock-oneshot-sha.patch
new file mode 100644
index 0000000000..d673cdaba8
--- /dev/null
+++ b/core/openssl/openssl-0.9.8k-padlock-oneshot-sha.patch
@@ -0,0 +1,605 @@
+#
+# OpenSSL patch to support VIA C7 hash engine in oneshot mode
+# Based on patch by: Michal Ludvig <michal@logix.cz>
+# http://www.logix.cz/michal/devel/padlock
+# Modified for oneshot mode by: Timo Teras <timo.teras@iki.fi>
+#
+Index: openssl-0.9.8k/crypto/engine/eng_padlock.c
+===================================================================
+--- openssl-0.9.8k.orig/crypto/engine/eng_padlock.c 2009-07-12 12:01:36.000000000 +0300
++++ openssl-0.9.8k/crypto/engine/eng_padlock.c 2009-07-12 13:02:30.000000000 +0300
+@@ -1,10 +1,11 @@
+-/*
++/*
+ * Support for VIA PadLock Advanced Cryptography Engine (ACE)
+ * Written by Michal Ludvig <michal@logix.cz>
+ * http://www.logix.cz/michal
++ * Oneshot SHA mode by Timo Teras <timo.teras@iki.fi>
+ *
+- * Big thanks to Andy Polyakov for a help with optimization,
+- * assembler fixes, port to MS Windows and a lot of other
++ * Big thanks to Andy Polyakov for a help with optimization,
++ * assembler fixes, port to MS Windows and a lot of other
+ * valuable work on this engine!
+ */
+
+@@ -74,12 +75,23 @@
+ #ifndef OPENSSL_NO_AES
+ #include <openssl/aes.h>
+ #endif
++#ifndef OPENSSL_NO_SHA
++#include <openssl/sha.h>
++#endif
+ #include <openssl/rand.h>
+ #include <openssl/err.h>
+
+ #ifndef OPENSSL_NO_HW
+ #ifndef OPENSSL_NO_HW_PADLOCK
+
++/* PadLock RNG is disabled by default */
++#define PADLOCK_NO_RNG 1
++
++/* No ASM routines for SHA in MSC yet */
++#ifdef _MSC_VER
++#define OPENSSL_NO_SHA
++#endif
++
+ /* Attempt to have a single source for both 0.9.7 and 0.9.8 :-) */
+ #if (OPENSSL_VERSION_NUMBER >= 0x00908000L)
+ # ifndef OPENSSL_NO_DYNAMIC_ENGINE
+@@ -96,7 +108,7 @@
+ /* VIA PadLock AES is available *ONLY* on some x86 CPUs.
+ Not only that it doesn't exist elsewhere, but it
+ even can't be compiled on other platforms!
+-
++
+ In addition, because of the heavy use of inline assembler,
+ compiler choice is limited to GCC and Microsoft C. */
+ #undef COMPILE_HW_PADLOCK
+@@ -138,20 +150,41 @@
+ static int padlock_init(ENGINE *e);
+
+ /* RNG Stuff */
++#ifndef PADLOCK_NO_RNG
+ static RAND_METHOD padlock_rand;
++#endif
+
+ /* Cipher Stuff */
+ #ifndef OPENSSL_NO_AES
+ static int padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
+ #endif
+
++/* Digest Stuff */
++#ifndef OPENSSL_NO_SHA
++static int padlock_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
++#endif
++
+ /* Engine names */
+ static const char *padlock_id = "padlock";
+ static char padlock_name[100];
+
+ /* Available features */
+-static int padlock_use_ace = 0; /* Advanced Cryptography Engine */
+-static int padlock_use_rng = 0; /* Random Number Generator */
++enum padlock_flags {
++ PADLOCK_RNG = 0x01,
++ PADLOCK_ACE = 0x02,
++ PADLOCK_ACE2 = 0x04,
++ PADLOCK_PHE = 0x08,
++ PADLOCK_PMM = 0x10
++};
++enum padlock_flags padlock_flags;
++
++#define PADLOCK_HAVE_RNG (padlock_flags & PADLOCK_RNG)
++#define PADLOCK_HAVE_ACE (padlock_flags & (PADLOCK_ACE|PADLOCK_ACE2))
++#define PADLOCK_HAVE_ACE1 (padlock_flags & PADLOCK_ACE)
++#define PADLOCK_HAVE_ACE2 (padlock_flags & PADLOCK_ACE2)
++#define PADLOCK_HAVE_PHE (padlock_flags & PADLOCK_PHE)
++#define PADLOCK_HAVE_PMM (padlock_flags & PADLOCK_PMM)
++
+ #ifndef OPENSSL_NO_AES
+ static int padlock_aes_align_required = 1;
+ #endif
+@@ -165,25 +198,30 @@
+ /* Check available features */
+ padlock_available();
+
+-#if 1 /* disable RNG for now, see commentary in vicinity of RNG code */
+- padlock_use_rng=0;
+-#endif
+-
+ /* Generate a nice engine name with available features */
+ BIO_snprintf(padlock_name, sizeof(padlock_name),
+- "VIA PadLock (%s, %s)",
+- padlock_use_rng ? "RNG" : "no-RNG",
+- padlock_use_ace ? "ACE" : "no-ACE");
++ "VIA PadLock: %s%s%s%s%s",
++ padlock_flags ? "" : "not supported",
++ PADLOCK_HAVE_RNG ? "RNG " : "",
++ PADLOCK_HAVE_ACE ? (PADLOCK_HAVE_ACE2 ? "ACE2 " : "ACE ") : "",
++ PADLOCK_HAVE_PHE ? "PHE " : "",
++ PADLOCK_HAVE_PMM ? "PMM " : "");
+
+- /* Register everything or return with an error */
++ /* Register everything or return with an error */
+ if (!ENGINE_set_id(e, padlock_id) ||
+ !ENGINE_set_name(e, padlock_name) ||
+
+- !ENGINE_set_init_function(e, padlock_init) ||
++ !ENGINE_set_init_function(e, padlock_init)
+ #ifndef OPENSSL_NO_AES
+- (padlock_use_ace && !ENGINE_set_ciphers (e, padlock_ciphers)) ||
++ || (PADLOCK_HAVE_ACE && !ENGINE_set_ciphers (e, padlock_ciphers))
++#endif
++#ifndef OPENSSL_NO_SHA
++ || (PADLOCK_HAVE_PHE && !ENGINE_set_digests (e, padlock_digests))
++#endif
++#ifndef PADLOCK_NO_RNG
++ || (PADLOCK_HAVE_RNG && !ENGINE_set_RAND (e, &padlock_rand))
+ #endif
+- (padlock_use_rng && !ENGINE_set_RAND (e, &padlock_rand))) {
++ ) {
+ return 0;
+ }
+
+@@ -213,7 +251,7 @@
+ static int
+ padlock_init(ENGINE *e)
+ {
+- return (padlock_use_rng || padlock_use_ace);
++ return (padlock_flags);
+ }
+
+ /* This stuff is needed if this ENGINE is being compiled into a self-contained
+@@ -240,6 +278,14 @@
+
+ /* ===== Here comes the "real" engine ===== */
+
++#ifdef __GNUC__
++#define likely(x) __builtin_expect(!!(x), 1)
++#define unlikely(x) __builtin_expect(!!(x), 0)
++#else
++#define likely(x) (x)
++#define unlikely(x) (x)
++#endif
++
+ #ifndef OPENSSL_NO_AES
+ /* Some AES-related constants */
+ #define AES_BLOCK_SIZE 16
+@@ -247,7 +293,7 @@
+ #define AES_KEY_SIZE_192 24
+ #define AES_KEY_SIZE_256 32
+
+-/* Here we store the status information relevant to the
++/* Here we store the status information relevant to the
+ current context. */
+ /* BIG FAT WARNING:
+ * Inline assembler in PADLOCK_XCRYPT_ASM()
+@@ -306,7 +352,7 @@
+ {
+ int result = -1;
+
+- /* We're checking if the bit #21 of EFLAGS
++ /* We're checking if the bit #21 of EFLAGS
+ can be toggled. If yes = CPUID is available. */
+ asm volatile (
+ "pushf\n"
+@@ -322,7 +368,7 @@
+ "xorl %%eax, %%ecx\n"
+ "movl %%ecx, %0\n"
+ : "=r" (result) : : "eax", "ecx");
+-
++
+ return (result == 0);
+ }
+
+@@ -365,10 +411,22 @@
+ : "+a"(eax), "=d"(edx) : : "ecx");
+
+ /* Fill up some flags */
+- padlock_use_ace = ((edx & (0x3<<6)) == (0x3<<6));
+- padlock_use_rng = ((edx & (0x3<<2)) == (0x3<<2));
++ padlock_flags |= ((edx & (0x3<<3)) ? PADLOCK_RNG : 0);
++ padlock_flags |= ((edx & (0x3<<7)) ? PADLOCK_ACE : 0);
++ padlock_flags |= ((edx & (0x3<<9)) ? PADLOCK_ACE2 : 0);
++ padlock_flags |= ((edx & (0x3<<11)) ? PADLOCK_PHE : 0);
++ padlock_flags |= ((edx & (0x3<<13)) ? PADLOCK_PMM : 0);
+
+- return padlock_use_ace + padlock_use_rng;
++ return padlock_flags;
++}
++
++static inline void
++padlock_htonl_block(uint32_t *data, size_t count)
++{
++ while (count--) {
++ asm volatile ("bswapl %0" : "+r"(*data));
++ data++;
++ }
+ }
+
+ #ifndef OPENSSL_NO_AES
+@@ -377,17 +435,14 @@
+ padlock_bswapl(AES_KEY *ks)
+ {
+ size_t i = sizeof(ks->rd_key)/sizeof(ks->rd_key[0]);
+- unsigned int *key = ks->rd_key;
++ uint32_t *key = (uint32_t*) ks->rd_key;
+
+- while (i--) {
+- asm volatile ("bswapl %0" : "+r"(*key));
+- key++;
+- }
++ padlock_htonl_block(key, i);
+ }
+ #endif
+
+ /* Force key reload from memory to the CPU microcode.
+- Loading EFLAGS from the stack clears EFLAGS[30]
++ Loading EFLAGS from the stack clears EFLAGS[30]
+ which does the trick. */
+ static inline void
+ padlock_reload_key(void)
+@@ -423,7 +478,7 @@
+ }
+
+ /* Template for padlock_xcrypt_* modes */
+-/* BIG FAT WARNING:
++/* BIG FAT WARNING:
+ * The offsets used with 'leal' instructions
+ * describe items of the 'padlock_cipher_data'
+ * structure.
+@@ -475,7 +530,7 @@
+ * In case you wonder 'rep xcrypt*' instructions above are *not*
+ * affected by the Direction Flag and pointers advance toward
+ * larger addresses unconditionally.
+- */
++ */
+ static inline unsigned char *
+ padlock_memcpy(void *dst,const void *src,size_t n)
+ {
+@@ -501,7 +556,7 @@
+ _asm _emit 0x0f _asm _emit 0xa7 \
+ _asm _emit code
+
+-/* BIG FAT WARNING:
++/* BIG FAT WARNING:
+ * The offsets used with 'lea' instructions
+ * describe items of the 'padlock_cipher_data'
+ * structure.
+@@ -840,7 +895,7 @@
+ return 1;
+ }
+
+-/*
++/*
+ * Simplified version of padlock_aes_cipher() used when
+ * 1) both input and output buffers are at aligned addresses.
+ * or when
+@@ -895,7 +950,7 @@
+ # error "insane PADLOCK_CHUNK..."
+ #endif
+
+-/* Re-align the arguments to 16-Bytes boundaries and run the
++/* Re-align the arguments to 16-Bytes boundaries and run the
+ encryption function itself. This function is not AES-specific. */
+ static int
+ padlock_aes_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
+@@ -1157,6 +1212,300 @@
+
+ #endif /* OPENSSL_NO_AES */
+
++#ifndef OPENSSL_NO_SHA
++
++union sha_all_ctx {
++ SHA_CTX sha_ctx;
++ SHA256_CTX sha256_ctx; /* shared with SHA224 */
++ char sha_final[EVP_MAX_MD_SIZE];
++};
++
++typedef int (*f_sha_update)(void *c, const void *_data, size_t len);
++typedef int (*f_sha_final)(unsigned char *md, void *c);
++
++struct padlock_digest_data {
++ union sha_all_ctx ctx;
++ unsigned int size;
++ f_sha_update update;
++ f_sha_final final;
++};
++
++#define DIGEST_DATA(ctx) ((struct padlock_digest_data *)(ctx->md_data))
++
++static void
++padlock_do_sha1(char *out, const char *in, int count)
++{
++ /* We can't store directly to *out as it
++ * doesn't have to be aligned. But who cares,
++ * it's only a few bytes... */
++ char buf[128+16];
++ unsigned char *output = NEAREST_ALIGNED(buf);
++
++ ((uint32_t*)output)[0] = 0x67452301;
++ ((uint32_t*)output)[1] = 0xEFCDAB89;
++ ((uint32_t*)output)[2] = 0x98BADCFE;
++ ((uint32_t*)output)[3] = 0x10325476;
++ ((uint32_t*)output)[4] = 0xC3D2E1F0;
++
++ asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */
++ : "+S"(in), "+D"(output)
++ : "c"(count), "a"(0));
++
++ memcpy(out, output, 5 * sizeof(uint32_t));
++ padlock_htonl_block((uint32_t*)out, 5);
++}
++
++static void
++padlock_do_sha224(char *out, const char *in, int count)
++{
++ /* We can't store directly to *out as it
++ * doesn't have to be aligned. But who cares,
++ * it's only a few bytes... */
++ char buf[128+16];
++ unsigned char *output = NEAREST_ALIGNED(buf);
++
++ ((uint32_t*)output)[0] = 0xC1059ED8UL;
++ ((uint32_t*)output)[1] = 0x367CD507UL;
++ ((uint32_t*)output)[2] = 0x3070DD17UL;
++ ((uint32_t*)output)[3] = 0xF70E5939UL;
++ ((uint32_t*)output)[4] = 0xFFC00B31UL;
++ ((uint32_t*)output)[5] = 0x68581511UL;
++ ((uint32_t*)output)[6] = 0x64F98FA7UL;
++ ((uint32_t*)output)[7] = 0xBEFA4FA4UL;
++
++ asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */
++ : "+S"(in), "+D"(output)
++ : "c"(count), "a"(0));
++
++ memcpy(out, output, 7 * sizeof(uint32_t));
++ padlock_htonl_block((uint32_t*)out, 7);
++}
++
++static void
++padlock_do_sha256(char *out, const char *in, int count)
++{
++ /* We can't store directly to *out as it
++ * doesn't have to be aligned. But who cares,
++ * it's only a few bytes... */
++ char buf[128+16];
++ unsigned char *output = NEAREST_ALIGNED(buf);
++
++ ((uint32_t*)output)[0] = 0x6A09E667;
++ ((uint32_t*)output)[1] = 0xBB67AE85;
++ ((uint32_t*)output)[2] = 0x3C6EF372;
++ ((uint32_t*)output)[3] = 0xA54FF53A;
++ ((uint32_t*)output)[4] = 0x510E527F;
++ ((uint32_t*)output)[5] = 0x9B05688C;
++ ((uint32_t*)output)[6] = 0x1F83D9AB;
++ ((uint32_t*)output)[7] = 0x5BE0CD19;
++
++ asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */
++ : "+S"(in), "+D"(output)
++ : "c"(count), "a"(0));
++
++ memcpy(out, output, 8 * sizeof(uint32_t));
++ padlock_htonl_block((uint32_t*)out, 8);
++}
++
++static int
++padlock_do_final(unsigned char *md, void *ctx)
++{
++ struct padlock_digest_data *ddata = (struct padlock_digest_data *) ctx;
++ memcpy(md, ddata->ctx.sha_final, ddata->size);
++ return 1;
++}
++
++static int
++padlock_sha1_init(EVP_MD_CTX *ctx)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ if (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) {
++ ddata->update = (f_sha_update) padlock_do_sha1;
++ ddata->final = (f_sha_final) padlock_do_final;
++ } else {
++ SHA1_Init(&ddata->ctx.sha_ctx);
++ ddata->update = (f_sha_update) SHA1_Update;
++ ddata->final = (f_sha_final) SHA1_Final;
++ }
++ ddata->size = EVP_MD_CTX_size(ctx);
++
++ return 1;
++}
++
++static int
++padlock_sha224_init(EVP_MD_CTX *ctx)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ if (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) {
++ ddata->update = (f_sha_update) padlock_do_sha224;
++ ddata->final = (f_sha_final) padlock_do_final;
++ } else {
++ SHA224_Init(&ddata->ctx.sha256_ctx);
++ ddata->update = (f_sha_update) SHA224_Update;
++ ddata->final = (f_sha_final) SHA224_Final;
++ }
++ ddata->size = EVP_MD_CTX_size(ctx);
++
++ return 1;
++}
++
++static int
++padlock_sha256_init(EVP_MD_CTX *ctx)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ if(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) {
++ ddata->update = (f_sha_update) padlock_do_sha256;
++ ddata->final = (f_sha_final) padlock_do_final;
++ } else {
++ SHA256_Init(&ddata->ctx.sha256_ctx);
++ ddata->update = (f_sha_update) SHA256_Update;
++ ddata->final = (f_sha_final) SHA256_Final;
++ }
++ ddata->size = EVP_MD_CTX_size(ctx);
++
++ return 1;
++}
++
++static int
++padlock_sha_update(EVP_MD_CTX *ctx, const void *data, size_t length)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ return ddata->update(&ddata->ctx, data, length);
++}
++
++static int
++padlock_sha_final(EVP_MD_CTX *ctx, unsigned char *md)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ return ddata->final(md, &ddata->ctx);
++}
++
++static int
++padlock_sha_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
++{
++ struct padlock_digest_data *ddata_from = DIGEST_DATA(from);
++ struct padlock_digest_data *ddata_to = DIGEST_DATA(to);
++
++ memcpy(ddata_to, ddata_from, sizeof(struct padlock_digest_data));
++
++ return 1;
++}
++
++static int
++padlock_sha_cleanup(EVP_MD_CTX *ctx)
++{
++ struct padlock_digest_data *ddata = DIGEST_DATA(ctx);
++
++ memset(ddata, 0, sizeof(struct padlock_digest_data));
++
++ return 1;
++}
++
++static const EVP_MD padlock_sha1_md = {
++ NID_sha1,
++ NID_sha1WithRSAEncryption,
++ SHA_DIGEST_LENGTH,
++ EVP_MD_FLAG_ONESHOT,
++ padlock_sha1_init,
++ padlock_sha_update,
++ padlock_sha_final,
++ padlock_sha_copy,
++ padlock_sha_cleanup,
++ EVP_PKEY_RSA_method,
++ SHA_CBLOCK,
++ sizeof(struct padlock_digest_data),
++};
++
++static const EVP_MD padlock_sha224_md = {
++ NID_sha224,
++ NID_sha224WithRSAEncryption,
++ SHA224_DIGEST_LENGTH,
++ EVP_MD_FLAG_ONESHOT,
++ padlock_sha224_init,
++ padlock_sha_update,
++ padlock_sha_final,
++ padlock_sha_copy,
++ padlock_sha_cleanup,
++ EVP_PKEY_RSA_method,
++ SHA_CBLOCK,
++ sizeof(struct padlock_digest_data),
++};
++
++static const EVP_MD padlock_sha256_md = {
++ NID_sha256,
++ NID_sha256WithRSAEncryption,
++ SHA256_DIGEST_LENGTH,
++ EVP_MD_FLAG_ONESHOT,
++ padlock_sha256_init,
++ padlock_sha_update,
++ padlock_sha_final,
++ padlock_sha_copy,
++ padlock_sha_cleanup,
++ EVP_PKEY_RSA_method,
++ SHA_CBLOCK,
++ sizeof(struct padlock_digest_data),
++};
++
++static int padlock_digest_nids[] = {
++#if !defined(OPENSSL_NO_SHA)
++ NID_sha1,
++#endif
++#if !defined(OPENSSL_NO_SHA256)
++#if !defined(OPENSSL_NO_SHA224)
++ NID_sha224,
++#endif
++ NID_sha256,
++#endif
++};
++
++static int padlock_digest_nids_num = sizeof(padlock_digest_nids)/sizeof(padlock_digest_nids[0]);
++
++static int
++padlock_digests (ENGINE *e, const EVP_MD **digest, const int **nids, int nid)
++{
++ /* No specific digest => return a list of supported nids ... */
++ if (!digest) {
++ *nids = padlock_digest_nids;
++ return padlock_digest_nids_num;
++ }
++
++ /* ... or the requested "digest" otherwise */
++ switch (nid) {
++#if !defined(OPENSSL_NO_SHA)
++ case NID_sha1:
++ *digest = &padlock_sha1_md;
++ break;
++#endif
++
++#if !defined(OPENSSL_NO_SHA256)
++#if !defined(OPENSSL_NO_SHA224)
++ case NID_sha224:
++ *digest = &padlock_sha224_md;
++ break;
++#endif /* OPENSSL_NO_SHA224 */
++
++ case NID_sha256:
++ *digest = &padlock_sha256_md;
++ break;
++#endif /* OPENSSL_NO_SHA256 */
++
++ default:
++ /* Sorry, we don't support this NID */
++ *digest = NULL;
++ return 0;
++ }
++
++ return 1;
++}
++
++#endif /* OPENSSL_NO_SHA */
++
++#ifndef PADLOCK_NO_RNG
+ /* ===== Random Number Generator ===== */
+ /*
+ * This code is not engaged. The reason is that it does not comply
+@@ -1164,7 +1513,7 @@
+ * (posted at http://www.via.com.tw/en/viac3/c3.jsp) nor does it
+ * provide meaningful error control...
+ */
+-/* Wrapper that provides an interface between the API and
++/* Wrapper that provides an interface between the API and
+ the raw PadLock RNG */
+ static int
+ padlock_rand_bytes(unsigned char *output, int count)
+@@ -1212,6 +1561,7 @@
+ padlock_rand_bytes, /* pseudorand */
+ padlock_rand_status, /* rand status */
+ };
++#endif /* PADLOCK_NO_RNG */
+
+ #endif /* COMPILE_HW_PADLOCK */
+