mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-23 13:43:44 +08:00
Update demos
To build demos, run `cmake .. -DENABLE_DEMOS=ON`
This commit is contained in:
38
demos/src/sm3_hmac_demo.c
Normal file
38
demos/src/sm3_hmac_demo.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmssl/sm3.h>
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned char key[16] = {
|
||||
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
0x01,0xf2,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
};
|
||||
unsigned char data[16] = {
|
||||
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
|
||||
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
|
||||
};
|
||||
unsigned char hmac[32] = {0};
|
||||
int i;
|
||||
|
||||
sm3_hmac(key, sizeof(key), data, sizeof(data), hmac);
|
||||
|
||||
printf("hmac: ");
|
||||
for (i = 0; i < sizeof(hmac); i++) {
|
||||
printf("%02x", hmac[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user