• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <gmssl/sm3.h>
14 
15 
main(void)16 int main(void)
17 {
18 	SM3_KDF_CTX kdf_ctx;
19 	unsigned char key[16] = {0};
20 	unsigned char raw[32] = {
21 		0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
22 		0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
23 	};
24 	int i;
25 
26 	sm3_kdf_init(&kdf_ctx, sizeof(key));
27 	sm3_kdf_update(&kdf_ctx, raw, sizeof(raw));
28 	sm3_kdf_finish(&kdf_ctx, key);
29 
30 	printf("key: ");
31 	for (i = 0; i < sizeof(key); i++) {
32 		printf("%02X", key[i]);
33 	}
34 	printf("\n");
35 
36 	return 0;
37 }
38