Build without support for the specified algorithm, where
<alg> is one of: bf, blake2, camellia, cast, chacha, cmac,
des, dh, dsa, ecdh, ecdsa, idea, md4, mdc2, ocb, poly1305,
- rc2, rc4, rmd160, scrypt, seed, siphash, sm3, sm4 or
- whirlpool. The "ripemd" algorithm is deprecated and if used
- is synonymous with rmd160.
+ rc2, rc4, rmd160, scrypt, seed, siphash, sm3, sm4 or
+ whirlpool. The "ripemd" algorithm is deprecated and if used
+ is synonymous with rmd160.
-Dxxx, lxxx, -Lxxx, -Wl, -rpath, -R, -framework, -static
These system specific options will be recognised and
e_rc4.c e_aes.c names.c e_seed.c e_aria.c e_sm4.c \
e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
m_null.c m_md2.c m_md4.c m_md5.c m_sha1.c m_wp.c \
- m_md5_sha1.c m_mdc2.c m_ripemd.c m_sha3.c m_sm3.c \
+ m_md5_sha1.c m_mdc2.c m_ripemd.c m_sha3.c \
p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
c_allc.c c_alld.c evp_lib.c bio_ok.c \
+++ /dev/null
-/*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright 2017 Ribose Inc. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include "internal/cryptlib.h"
-
-#ifndef OPENSSL_NO_SM3
-
-# include <openssl/evp.h>
-# include <openssl/objects.h>
-# include <openssl/sm3.h>
-# include "internal/evp_int.h"
-
-static int init(EVP_MD_CTX *ctx)
-{
- return SM3_Init(EVP_MD_CTX_md_data(ctx));
-}
-
-static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- return SM3_Update(EVP_MD_CTX_md_data(ctx), data, count);
-}
-
-static int final(EVP_MD_CTX *ctx, unsigned char *md)
-{
- return SM3_Final(md, EVP_MD_CTX_md_data(ctx));
-}
-
-static const EVP_MD sm3_md = {
- NID_sm3,
- NID_sm3WithRSAEncryption,
- SM3_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- SM3_CBLOCK,
- sizeof(EVP_MD *) + sizeof(SM3_CTX),
-};
-
-const EVP_MD *EVP_sm3(void)
-{
- return &sm3_md;
-}
-#endif
-
--- /dev/null
+/*
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017 Ribose Inc. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef HEADER_SM3_H
+# define HEADER_SM3_H
+
+# include <openssl/opensslconf.h>
+
+# ifdef OPENSSL_NO_SM3
+# error SM3 is disabled.
+# endif
+
+# define SM3_DIGEST_LENGTH 32
+# define SM3_WORD unsigned int
+
+# define SM3_CBLOCK 64
+# define SM3_LBLOCK (SM3_CBLOCK/4)
+
+typedef struct SM3state_st {
+ SM3_WORD A, B, C, D, E, F, G, H;
+ SM3_WORD Nl, Nh;
+ SM3_WORD data[SM3_LBLOCK];
+ unsigned int num;
+} SM3_CTX;
+
+int sm3_init(SM3_CTX *c);
+int sm3_update(SM3_CTX *c, const void *data, size_t len);
+int sm3_final(unsigned char *md, SM3_CTX *c);
+
+void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
+
+#endif
LIBS=../../libcrypto
-SOURCE[../../libcrypto]=sm3.c
+SOURCE[../../libcrypto]=sm3.c m_sm3.c
--- /dev/null
+/*
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017 Ribose Inc. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "internal/cryptlib.h"
+
+#ifndef OPENSSL_NO_SM3
+# include <openssl/evp.h>
+# include "internal/evp_int.h"
+# include "internal/sm3.h"
+
+static int init(EVP_MD_CTX *ctx)
+{
+ return sm3_init(EVP_MD_CTX_md_data(ctx));
+}
+
+static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
+{
+ return sm3_update(EVP_MD_CTX_md_data(ctx), data, count);
+}
+
+static int final(EVP_MD_CTX *ctx, unsigned char *md)
+{
+ return sm3_final(md, EVP_MD_CTX_md_data(ctx));
+}
+
+static const EVP_MD sm3_md = {
+ NID_sm3,
+ NID_sm3WithRSAEncryption,
+ SM3_DIGEST_LENGTH,
+ 0,
+ init,
+ update,
+ final,
+ NULL,
+ NULL,
+ SM3_CBLOCK,
+ sizeof(EVP_MD *) + sizeof(SM3_CTX),
+};
+
+const EVP_MD *EVP_sm3(void)
+{
+ return &sm3_md;
+}
+
+#endif
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
-
-#ifndef OPENSSL_NO_SM3
-
+#include <openssl/e_os2.h>
#include "sm3_locl.h"
-#include <openssl/opensslv.h>
-int SM3_Init(SM3_CTX *c)
+int sm3_init(SM3_CTX *c)
{
memset(c, 0, sizeof(*c));
c->A = SM3_A;
return 1;
}
-unsigned char *SM3(const unsigned char *d, size_t n, unsigned char *md)
-{
- SM3_CTX c;
- static unsigned char m[SM3_DIGEST_LENGTH];
-
- if (md == NULL)
- md = m;
- if (!SM3_Init(&c))
- return NULL;
- SM3_Update(&c, d, n);
- SM3_Final(md, &c);
- OPENSSL_cleanse(&c, sizeof(c)); /* security consideration */
- return md;
-}
-
void sm3_block_data_order(SM3_CTX *ctx, const void *p, size_t num)
{
const unsigned char *data = p;
ctx->H ^= H;
}
}
-#endif
+
* https://www.openssl.org/source/license.html
*/
-#include <stdlib.h>
#include <string.h>
-#include <openssl/e_os2.h>
-#include <openssl/sm3.h>
-
-void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);
+#include "internal/sm3.h"
#define DATA_ORDER_IS_BIG_ENDIAN
#define HASH_LONG SM3_WORD
#define HASH_CTX SM3_CTX
#define HASH_CBLOCK SM3_CBLOCK
-#define HASH_UPDATE SM3_Update
-#define HASH_TRANSFORM SM3_Transform
-#define HASH_FINAL SM3_Final
-#define HASH_MAKE_STRING(c,s) do { \
- unsigned long ll; \
- ll=(c)->A; (void)HOST_l2c(ll,(s)); \
- ll=(c)->B; (void)HOST_l2c(ll,(s)); \
- ll=(c)->C; (void)HOST_l2c(ll,(s)); \
- ll=(c)->D; (void)HOST_l2c(ll,(s)); \
- ll=(c)->E; (void)HOST_l2c(ll,(s)); \
- ll=(c)->F; (void)HOST_l2c(ll,(s)); \
- ll=(c)->G; (void)HOST_l2c(ll,(s)); \
- ll=(c)->H; (void)HOST_l2c(ll,(s)); \
- } while (0)
+#define HASH_UPDATE sm3_update
+#define HASH_TRANSFORM sm3_transform
+#define HASH_FINAL sm3_final
+#define HASH_MAKE_STRING(c, s) \
+ do { \
+ unsigned long ll; \
+ ll=(c)->A; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->B; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->C; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->D; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->E; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->F; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->G; (void)HOST_l2c(ll, (s)); \
+ ll=(c)->H; (void)HOST_l2c(ll, (s)); \
+ } while (0)
#define HASH_BLOCK_DATA_ORDER sm3_block_data_order
+void sm3_transform(SM3_CTX *c, const unsigned char *data);
+
#include "internal/md32_common.h"
#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17))
#define EXPAND(W0,W7,W13,W3,W10) \
(P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10)
-#define RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF,GG) do { \
- const SM3_WORD A12 = ROTATE(A, 12); \
- const SM3_WORD A12_SM = A12 + E + TJ; \
- const SM3_WORD SS1 = ROTATE(A12_SM, 7); \
- const SM3_WORD TT1 = FF(A,B,C) + D + (SS1 ^ A12) + (Wj); \
- const SM3_WORD TT2 = GG(E,F,G) + H + SS1 + Wi; \
- B = ROTATE(B, 9); \
- D = TT1; \
- F = ROTATE(F, 19); \
- H = P0(TT2); \
- } while(0);
+#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \
+ do { \
+ const SM3_WORD A12 = ROTATE(A, 12); \
+ const SM3_WORD A12_SM = A12 + E + TJ; \
+ const SM3_WORD SS1 = ROTATE(A12_SM, 7); \
+ const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \
+ const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \
+ B = ROTATE(B, 9); \
+ D = TT1; \
+ F = ROTATE(F, 19); \
+ H = P0(TT2); \
+ } while(0)
#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0)
L<EVP_sha1(3)>,
L<EVP_sha224(3)>,
L<EVP_sha3_224(3)>,
+L<EVP_sm3(3)>,
L<EVP_whirlpool(3)>
=head1 HISTORY
--- /dev/null
+=pod
+
+=head1 NAME
+
+EVP_sm3
+- SM3 for EVP
+
+=head1 SYNOPSIS
+
+ #include <openssl/evp.h>
+
+ const EVP_MD *EVP_sm3(void)
+
+=head1 DESCRIPTION
+
+SM3 is a cryptographic hash function with a 256-bit output, defined in GB/T
+32905-2016.
+
+=over 4
+
+=item EVP_sm3()
+
+The SM3 hash function.
+
+=back
+
+
+=head1 RETURN VALUES
+
+These functions return a B<EVP_MD> structure that contains the
+implementation of the symmetric cipher. See L<EVP_MD_meth_new(3)> for
+details of the B<EVP_MD> structure.
+
+=head1 CONFORMING TO
+
+GB/T 32905-2016 and GM/T 0004-2012.
+
+=head1 SEE ALSO
+
+L<evp(7)>,
+L<EVP_DigestInit(3)>
+
+=head1 COPYRIGHT
+
+Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2017 Ribose Inc. All Rights Reserved.
+
+Licensed under the OpenSSL license (the "License"). You may not use
+this file except in compliance with the License. You can obtain a copy
+in the file LICENSE in the source distribution or at
+L<https://www.openssl.org/source/license.html>.
+
+=cut
+
+++ /dev/null
-=pod
-
-=head1 NAME
-
-SM3_Init,
-SM3_Update,
-SM3_Final
-
-=head1 SYNOPSIS
-
- #include <openssl/sm3.h>
-
- unsigned char *SM3(const unsigned char *d, size_t n, unsigned char *md);
-
- int SM3_Init(SM3_CTX *c);
- int SM3_Update(SM3_CTX *c, const void *data, size_t len);
- int SM3_Final(unsigned char *md, SM3_CTX *c);
-
-=head1 DESCRIPTION
-
-SM3 is a cryptographic hash function with a 256-bit output, defined in GB/T
-32905-2016.
-
-SM3() computes the SM3 message digest of the B<n> bytes at B<d> and places it
-in B<md> (which must have space for SM3_DIGEST_LENGTH == 32 bytes of output).
-If B<md> is NULL, the digest is placed in a static array.
-
-The following functions may be used if the message is not completely stored in
-memory:
-
-SM3_Init() initializes a B<SM3_CTX> structure.
-
-SM3_Update() can be called repeatedly with chunks of the message to be hashed
-(B<len> bytes at B<data>).
-
-SM3_Final() places the message digest in B<md>, which must have space for
-B<SM3_DIGEST_LENGTH> == 32 bytes of output, and erases the B<SM3_CTX>.
-
-=head1 RETURN VALUES
-
-=over 4
-
-=item SM3()
-
-Returns pointers to the hash value.
-
-=item SM3_Init(), SM3_Update(), SM3_Final()
-
-Returns 1 for success, 0 otherwise.
-
-=back
-
-=head1 NOTE
-
-Applications should use the higher level functions such as L<EVP_DigestInit(3)>
-instead of calling these functions directly.
-
-=head1 CONFORMING TO
-
-GB/T 32905-2016 and GM/T 0004-2012.
-
-=head1 SEE ALSO
-
-L<EVP_DigestInit(3)>
-
-=head1 COPYRIGHT
-
-Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
-Copyright 2017 Ribose Inc. All Rights Reserved.
-
-Licensed under the OpenSSL license (the "License"). You may not use
-this file except in compliance with the License. You can obtain a copy
-in the file LICENSE in the source distribution or at
-L<https://www.openssl.org/source/license.html>.
-
-=cut
OBJ_ISO_CN="\x2A\x81\x1C"
OBJ_oscca="\x2A\x81\x1C\xCF\x55"
OBJ_sm_scheme="\x2A\x81\x1C\xCF\x55\x01"
+OBJ_sm3="\x2A\x81\x1C\xCF\x55\x01\x83\x11"
+OBJ_sm3WithRSAEncryption="\x2A\x81\x1C\xCF\x55\x01\x83\x78"
+++ /dev/null
-/*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright 2017 [Ribose Inc.](https://www.ribose.com). All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#ifndef HEADER_SM3_H
-# define HEADER_SM3_H
-
-# include <openssl/opensslconf.h>
-
-# ifdef OPENSSL_NO_SM3
-# error SM3 is disabled.
-# endif
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-#define SM3_DIGEST_LENGTH 32
-#define SM3_WORD unsigned int
-
-# define SM3_CBLOCK 64
-# define SM3_LBLOCK (SM3_CBLOCK/4)
-
-typedef struct SM3state_st {
- SM3_WORD A, B, C, D, E, F, G, H;
- SM3_WORD Nl, Nh;
- SM3_WORD data[SM3_LBLOCK];
- unsigned int num;
-} SM3_CTX;
-
-int SM3_Init(SM3_CTX *c);
-int SM3_Update(SM3_CTX *c, const void *data, size_t len);
-int SM3_Final(unsigned char *md, SM3_CTX *c);
-void SM3_Transform(SM3_CTX *c, const unsigned char *data);
-unsigned char *SM3(const unsigned char *d, size_t n, unsigned char *md);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
EVP_sm4_ecb 4371 1_1_1 EXIST::FUNCTION:SM4
EVP_sm4_cfb128 4372 1_1_1 EXIST::FUNCTION:SM4
EVP_sm3 4373 1_1_1 EXIST::FUNCTION:SM3
-SM3_Update 4374 1_1_1 EXIST::FUNCTION:SM3
-SM3 4375 1_1_1 EXIST::FUNCTION:SM3
-SM3_Init 4376 1_1_1 EXIST::FUNCTION:SM3
-SM3_Final 4377 1_1_1 EXIST::FUNCTION:SM3