• 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 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include "../sgd.h"
15 #include "sdf.h"
16 
17 static char *deviceHandle = "SDF Device Handle";
18 static char *sessionHandle = "SDF Session Handle";
19 static char *keyHandle = "SDF Key Handle";
20 static char *agreementHandle = "SDF Agreement Handle";
21 
22 unsigned char rsaPublicKeyBuf[516] = {
23 	0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
24 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
25 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
26 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
28 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
29 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
30 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
31 	0x00,0x00,0x00,0x00,0xd5,0x43,0xbf,0x24,0xd2,0x69,0x56,0x21,0x20,0x57,0x8a,0xd8,
32 	0x67,0x4f,0xbd,0xd5,0xf5,0x3a,0xf5,0x9e,0xa5,0x87,0x52,0x39,0x47,0xc3,0xce,0x32,
33 	0x56,0xb6,0x06,0x2d,0xdc,0x8d,0xc2,0x18,0x53,0x5c,0xb0,0xcb,0xb6,0xe8,0x7c,0x82,
34 	0x97,0x38,0xbb,0x85,0x45,0x2e,0xc8,0x24,0x08,0x96,0x9e,0xb0,0x00,0xaf,0xd9,0xa7,
35 	0x1f,0x50,0x7f,0xc4,0x93,0x14,0x74,0x9a,0x43,0x8e,0x04,0x95,0xa0,0xd6,0xd9,0xdd,
36 	0xb4,0x97,0xb3,0x52,0x93,0xe4,0xbe,0xd1,0x1f,0x8c,0xf9,0xcd,0xe1,0xae,0x54,0xae,
37 	0x72,0xdf,0x94,0xe3,0x15,0x6a,0x5c,0x99,0xd6,0x80,0x46,0x94,0xad,0xb3,0x76,0x95,
38 	0x4e,0x14,0x8f,0x8f,0xe5,0x55,0xf1,0x3f,0xd0,0xd3,0x96,0x01,0xf6,0x94,0x3e,0x61,
39 	0xc1,0x8e,0xb3,0x89,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
41 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
42 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
43 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
44 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
45 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
46 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
48 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
49 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
50 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
52 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
53 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
55 	0x00,0x01,0x00,0x01,};
56 unsigned char rsaPrivateKeyBuf[1412] = {
57 	0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
58 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
59 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
60 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
61 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
62 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
63 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
64 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
65 	0x00,0x00,0x00,0x00,0xd5,0x43,0xbf,0x24,0xd2,0x69,0x56,0x21,0x20,0x57,0x8a,0xd8,
66 	0x67,0x4f,0xbd,0xd5,0xf5,0x3a,0xf5,0x9e,0xa5,0x87,0x52,0x39,0x47,0xc3,0xce,0x32,
67 	0x56,0xb6,0x06,0x2d,0xdc,0x8d,0xc2,0x18,0x53,0x5c,0xb0,0xcb,0xb6,0xe8,0x7c,0x82,
68 	0x97,0x38,0xbb,0x85,0x45,0x2e,0xc8,0x24,0x08,0x96,0x9e,0xb0,0x00,0xaf,0xd9,0xa7,
69 	0x1f,0x50,0x7f,0xc4,0x93,0x14,0x74,0x9a,0x43,0x8e,0x04,0x95,0xa0,0xd6,0xd9,0xdd,
70 	0xb4,0x97,0xb3,0x52,0x93,0xe4,0xbe,0xd1,0x1f,0x8c,0xf9,0xcd,0xe1,0xae,0x54,0xae,
71 	0x72,0xdf,0x94,0xe3,0x15,0x6a,0x5c,0x99,0xd6,0x80,0x46,0x94,0xad,0xb3,0x76,0x95,
72 	0x4e,0x14,0x8f,0x8f,0xe5,0x55,0xf1,0x3f,0xd0,0xd3,0x96,0x01,0xf6,0x94,0x3e,0x61,
73 	0xc1,0x8e,0xb3,0x89,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
74 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
75 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
76 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
80 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
81 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
82 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
83 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
84 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
85 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
86 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
87 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
88 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
89 	0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
90 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
91 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
92 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
93 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
94 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
95 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
96 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
97 	0x00,0x00,0x00,0x00,0x1e,0xd9,0x55,0xe4,0xf5,0xaa,0xd7,0x12,0xa3,0xa3,0x06,0x2a,
98 	0x97,0x87,0x29,0x66,0xb1,0xba,0x7d,0x9d,0x1d,0x44,0x9d,0xd8,0x3b,0x51,0x4f,0x9a,
99 	0x68,0x80,0x9c,0x14,0x36,0x3b,0x2b,0x40,0x69,0x8e,0x96,0xe4,0x60,0xe8,0xf0,0x59,
100 	0xd3,0x96,0x19,0x4a,0x05,0xdf,0xe6,0x83,0x8f,0xda,0x79,0xc9,0xeb,0xcf,0x84,0x24,
101 	0x70,0x9b,0x2c,0x5f,0xf7,0x56,0xe2,0xe0,0xc7,0xfb,0x67,0x92,0xd2,0xf6,0x59,0x19,
102 	0xe9,0xdd,0xb4,0x54,0x52,0x0d,0xf8,0xda,0x64,0x67,0xe0,0xb9,0xe6,0x52,0x08,0xff,
103 	0x28,0x06,0x89,0x5c,0x2b,0xd5,0x6e,0x21,0xe1,0x6d,0x1d,0xe3,0xf8,0x1e,0x0f,0x20,
104 	0x9f,0x0a,0x60,0xd1,0xff,0x4e,0xa2,0x45,0xa1,0xee,0x96,0x90,0xc0,0xc4,0xa8,0x25,
105 	0x5a,0xe8,0xe8,0xa1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
106 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
107 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
108 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
109 	0x00,0x00,0x00,0x00,0xf5,0xde,0x0d,0x0c,0xc5,0x03,0x53,0x44,0xfa,0x70,0xc7,0x44,
110 	0x63,0xf8,0x57,0x7e,0x49,0x76,0xe4,0x7a,0x76,0x01,0x7d,0xda,0x65,0xaa,0x9d,0xbe,
111 	0xfe,0x24,0x9b,0x48,0xf9,0xa8,0x18,0x42,0x47,0xf3,0x1a,0x1e,0x61,0xe9,0xb8,0xb3,
112 	0x07,0xee,0xfd,0x83,0x2e,0xf2,0xf8,0xb9,0x1f,0x9a,0xee,0xeb,0x21,0xd0,0xc0,0x13,
113 	0xa2,0x31,0x33,0xe7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
114 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
115 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
116 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
117 	0x00,0x00,0x00,0x00,0xde,0x0d,0xba,0xf3,0x62,0x8f,0x75,0x16,0xe6,0x87,0x72,0xba,
118 	0x12,0x6a,0x43,0x5c,0xde,0x22,0x60,0xea,0xef,0x7a,0x7e,0xb6,0x28,0x16,0x4f,0xda,
119 	0xe7,0xb8,0xfe,0x48,0x17,0x65,0x1a,0x73,0x38,0x98,0xdb,0xa2,0xda,0x50,0xc8,0x81,
120 	0x53,0x07,0x1d,0x0e,0xa7,0x3f,0x48,0x57,0xea,0x5b,0x34,0x64,0x9f,0x0a,0x8b,0x36,
121 	0x7e,0x08,0xef,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
122 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
123 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
124 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
125 	0x00,0x00,0x00,0x00,0xa8,0xd9,0xe6,0x7c,0x6e,0x90,0xea,0x0e,0xe5,0x2f,0xae,0xa9,
126 	0xf9,0x3e,0x04,0x58,0x66,0x7b,0x90,0x4d,0xc9,0xdd,0x1c,0x61,0x70,0x90,0xcb,0xe4,
127 	0xef,0x04,0x94,0xe0,0x79,0x14,0x48,0x14,0xbc,0xf4,0xe7,0x6b,0x16,0x33,0x3c,0xf5,
128 	0x36,0xed,0x9a,0x8d,0x0d,0x21,0x30,0x4f,0x72,0xb5,0x24,0x7f,0xb6,0xa9,0x76,0x40,
129 	0x05,0x93,0x64,0xe1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
130 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
131 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
132 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
133 	0x00,0x00,0x00,0x00,0x85,0x35,0x31,0x68,0x9e,0x40,0xb7,0x1a,0x34,0xd3,0x1e,0x84,
134 	0xf7,0x55,0x1d,0xf2,0x11,0x24,0x08,0x86,0x07,0x81,0xb1,0x8f,0xee,0xfe,0x6b,0x8b,
135 	0x43,0xa5,0x5b,0x8d,0xbd,0xd3,0x1e,0x09,0xee,0xf2,0xec,0x17,0x86,0xe6,0x1d,0x52,
136 	0x4f,0x8f,0x9d,0xe3,0xd3,0x7b,0x08,0x18,0x0d,0x74,0x07,0x3b,0x31,0x99,0x6e,0xa8,
137 	0x12,0xf5,0xa3,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
138 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
139 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
140 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
141 	0x00,0x00,0x00,0x00,0x23,0x60,0x23,0xc4,0x44,0x67,0x91,0xb7,0xde,0x06,0x9a,0x17,
142 	0x49,0x3a,0x8e,0x66,0xb4,0x54,0x61,0x4b,0xc4,0x9e,0xf8,0xe6,0xbc,0xf8,0x87,0xef,
143 	0x06,0xb5,0x40,0x4b,0xab,0xaf,0xf0,0xa0,0x46,0x43,0xc5,0xbd,0xec,0xff,0x57,0xfd,
144 	0x51,0x8a,0x6b,0x7b,0x32,0xee,0xeb,0x2f,0x81,0xd0,0xa0,0xa2,0x09,0x18,0xab,0x5c,
145 	0x85,0x1b,0x0f,0x57,};
146 unsigned char eccPublicKeyBuf[132] = {
147 	0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
148 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
149 	0x00,0x00,0x00,0x00,0x0e,0x42,0x92,0x4a,0x1b,0x01,0xb6,0x64,0x89,0x97,0xfb,0x67,
150 	0x3f,0xa5,0xa6,0xc4,0xc4,0x82,0xa2,0xfa,0xe6,0x96,0xc9,0x0a,0x37,0xf2,0x44,0x6c,
151 	0xac,0x37,0x85,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
152 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
153 	0x00,0x00,0x00,0x00,0xf8,0xbb,0x32,0x55,0xe2,0x47,0x34,0x9a,0xc9,0xb5,0xdb,0xc7,
154 	0x17,0x4a,0xd9,0x84,0xbf,0xc5,0x3e,0x99,0x92,0xc6,0xd8,0x2d,0x6f,0xea,0xff,0x79,
155 	0x6b,0xde,0x3d,0x37,};
156 unsigned char eccPrivateKeyBuf[68] = {
157 	0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
158 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
159 	0x00,0x00,0x00,0x00,0xe6,0x51,0x2e,0xf8,0xca,0x14,0x84,0xa2,0xd9,0x76,0xc9,0x0d,
160 	0x37,0x1d,0xf1,0x95,0x49,0xbe,0x83,0x8e,0x70,0x09,0x1d,0x81,0xbd,0x6e,0xd9,0x5c,
161 	0xad,0x02,0x19,0x44,};
162 
163 
164 #define SDF_TRACE() fprintf(stderr, "SDF_Dummy->%s\n", __FUNCTION__)
165 
SDF_OpenDevice(void ** phDeviceHandle)166 int SDF_OpenDevice(
167 	void **phDeviceHandle)
168 {
169 	if (!phDeviceHandle /* || !(*phDeviceHandle) */)
170 		return SDR_INARGERR;
171 
172 	*phDeviceHandle = deviceHandle;
173 	return SDR_OK;
174 }
175 
SDF_CloseDevice(void * hDeviceHandle)176 int SDF_CloseDevice(
177 	void *hDeviceHandle)
178 {
179 	return SDR_OK;
180 }
181 
SDF_OpenSession(void * hDeviceHandle,void ** phSessionHandle)182 int SDF_OpenSession(
183 	void *hDeviceHandle,
184 	void **phSessionHandle)
185 {
186 	if (!phSessionHandle  /* || !(*phSessionHandle) */)
187 		return SDR_INARGERR;
188 	*phSessionHandle = sessionHandle;
189 	return SDR_OK;
190 }
191 
SDF_CloseSession(void * hSessionHandle)192 int SDF_CloseSession(
193 	void *hSessionHandle)
194 {
195 	return SDR_OK;
196 }
197 
198 #define SDF_DEV_DATE		"20140101"
199 #define SDF_DEV_BATCH_NUM	"001"
200 #define SDF_DEV_SERIAL_NUM	"00123"
201 #define SDF_DEV_SERIAL		SDF_DEV_DATE \
202 				SDF_DEV_BATCH_NUM \
203 				SDF_DEV_SERIAL_NUM
204 
SDF_GetDeviceInfo(void * hSessionHandle,DEVICEINFO * pstDeviceInfo)205 int SDF_GetDeviceInfo(
206 	void *hSessionHandle,
207 	DEVICEINFO *pstDeviceInfo)
208 {
209 	if (!pstDeviceInfo)
210 		return SDR_INARGERR;
211 	memset(pstDeviceInfo, 0, sizeof(*pstDeviceInfo));
212 	strncpy((char *)pstDeviceInfo->IssuerName, "GmSSL Project (http://gmssl.org)",
213 		sizeof(pstDeviceInfo->IssuerName));
214 	strncpy((char *)pstDeviceInfo->DeviceName, "Dummy SDF",
215 		sizeof(pstDeviceInfo->DeviceName));
216 	strncpy((char *)pstDeviceInfo->DeviceSerial, SDF_DEV_SERIAL,
217 		sizeof(pstDeviceInfo->DeviceSerial));
218 	pstDeviceInfo->DeviceVersion = 1;
219 	pstDeviceInfo->StandardVersion = 1;
220 	pstDeviceInfo->AsymAlgAbility[0] = SGD_RSA_SIGN|SGD_RSA_ENC|
221 		SGD_SM2_1|SGD_SM2_2|SGD_SM2_3;
222 	pstDeviceInfo->AsymAlgAbility[1] = 256|512|1024|2048|4096;
223 	pstDeviceInfo->SymAlgAbility = SGD_SM1|SGD_SSF33|SGD_SM4|SGD_ZUC|
224 		SGD_ECB|SGD_CBC|SGD_CFB|SGD_OFB|SGD_MAC;
225 	pstDeviceInfo->HashAlgAbility = SGD_SM3|SGD_SHA1|SGD_SHA256;
226 	pstDeviceInfo->BufferSize = 256*1024;
227 	return SDR_OK;
228 }
229 
SDF_GenerateRandom(void * hSessionHandle,unsigned int uiLength,unsigned char * pucRandom)230 int SDF_GenerateRandom(
231 	void *hSessionHandle,
232 	unsigned int uiLength,
233 	unsigned char *pucRandom)
234 {
235 	return SDR_OK;
236 }
237 
SDF_GetPrivateKeyAccessRight(void * hSessionHandle,unsigned int uiKeyIndex,unsigned char * pucPassword,unsigned int uiPwdLength)238 int SDF_GetPrivateKeyAccessRight(
239 	void *hSessionHandle,
240 	unsigned int uiKeyIndex,
241 	unsigned char *pucPassword,
242 	unsigned int uiPwdLength)
243 {
244 	return SDR_OK;
245 }
246 
SDF_ReleasePrivateKeyAccessRight(void * hSessionHandle,unsigned int uiKeyIndex)247 int SDF_ReleasePrivateKeyAccessRight(
248 	void *hSessionHandle,
249 	unsigned int uiKeyIndex)
250 {
251 	return SDR_OK;
252 }
253 
SDF_ExportSignPublicKey_RSA(void * hSessionHandle,unsigned int uiKeyIndex,RSArefPublicKey * pucPublicKey)254 int SDF_ExportSignPublicKey_RSA(
255 	void *hSessionHandle,
256 	unsigned int uiKeyIndex,
257 	RSArefPublicKey *pucPublicKey)
258 {
259 	if (!pucPublicKey)
260 		return SDR_INARGERR;
261 	memcpy(pucPublicKey, rsaPublicKeyBuf, sizeof(*pucPublicKey));
262 	return SDR_OK;
263 }
264 
SDF_ExportEncPublicKey_RSA(void * hSessionHandle,unsigned int uiKeyIndex,RSArefPublicKey * pucPublicKey)265 int SDF_ExportEncPublicKey_RSA(
266 	void *hSessionHandle,
267 	unsigned int uiKeyIndex,
268 	RSArefPublicKey *pucPublicKey)
269 {
270 	if (!pucPublicKey)
271 		return SDR_INARGERR;
272 	memcpy(pucPublicKey, rsaPublicKeyBuf, sizeof(*pucPublicKey));
273 	return SDR_OK;
274 }
275 
SDF_GenerateKeyPair_RSA(void * hSessionHandle,unsigned int uiKeyBits,RSArefPublicKey * pucPublicKey,RSArefPrivateKey * pucPrivateKey)276 int SDF_GenerateKeyPair_RSA(
277 	void *hSessionHandle,
278 	unsigned int uiKeyBits,
279 	RSArefPublicKey *pucPublicKey,
280 	RSArefPrivateKey *pucPrivateKey)
281 {
282 	if (!pucPublicKey || !pucPrivateKey)
283 		return SDR_INARGERR;
284 	memcpy(pucPublicKey, rsaPublicKeyBuf, sizeof(*pucPublicKey));
285 	memcpy(pucPrivateKey, rsaPrivateKeyBuf, sizeof(*pucPrivateKey));
286 	return SDR_OK;
287 }
288 
SDF_GenerateKeyWithIPK_RSA(void * hSessionHandle,unsigned int uiIPKIndex,unsigned int uiKeyBits,unsigned char * pucKey,unsigned int * puiKeyLength,void ** phKeyHandle)289 int SDF_GenerateKeyWithIPK_RSA(
290 	void *hSessionHandle,
291 	unsigned int uiIPKIndex,
292 	unsigned int uiKeyBits,
293 	unsigned char *pucKey,
294 	unsigned int *puiKeyLength,
295 	void **phKeyHandle)
296 {
297 	if (!puiKeyLength)
298 		return SDR_INARGERR;
299 	*puiKeyLength = 2048/8;
300 	if (phKeyHandle && *phKeyHandle)
301 		*phKeyHandle = keyHandle;
302 	return SDR_OK;
303 }
304 
SDF_GenerateKeyWithEPK_RSA(void * hSessionHandle,unsigned int uiKeyBits,RSArefPublicKey * pucPublicKey,unsigned char * pucKey,unsigned int * puiKeyLength,void ** phKeyHandle)305 int SDF_GenerateKeyWithEPK_RSA(
306 	void *hSessionHandle,
307 	unsigned int uiKeyBits,
308 	RSArefPublicKey *pucPublicKey,
309 	unsigned char *pucKey,
310 	unsigned int *puiKeyLength,
311 	void **phKeyHandle)
312 {
313 	if (!puiKeyLength)
314 		return SDR_INARGERR;
315 	*puiKeyLength = 2048/8;
316 	if (phKeyHandle && *phKeyHandle)
317 		*phKeyHandle = keyHandle;
318 	return SDR_OK;
319 }
320 
SDF_ImportKeyWithISK_RSA(void * hSessionHandle,unsigned int uiISKIndex,unsigned char * pucKey,unsigned int uiKeyLength,void ** phKeyHandle)321 int SDF_ImportKeyWithISK_RSA(
322 	void *hSessionHandle,
323 	unsigned int uiISKIndex,
324 	unsigned char *pucKey,
325 	unsigned int uiKeyLength,
326 	void **phKeyHandle)
327 {
328 	if (!phKeyHandle || !(*phKeyHandle))
329 		return SDR_INARGERR;
330 	*phKeyHandle = keyHandle;
331 	return SDR_OK;
332 }
333 
SDF_ExchangeDigitEnvelopeBaseOnRSA(void * hSessionHandle,unsigned int uiKeyIndex,RSArefPublicKey * pucPublicKey,unsigned char * pucDEInput,unsigned int uiDELength,unsigned char * pucDEOutput,unsigned int * puiDELength)334 int SDF_ExchangeDigitEnvelopeBaseOnRSA(
335 	void *hSessionHandle,
336 	unsigned int uiKeyIndex,
337 	RSArefPublicKey *pucPublicKey,
338 	unsigned char *pucDEInput,
339 	unsigned int uiDELength,
340 	unsigned char *pucDEOutput,
341 	unsigned int *puiDELength)
342 {
343 	if (!puiDELength)
344 		return SDR_INARGERR;
345 	*puiDELength = 2048/8;
346 	return SDR_OK;
347 }
348 
SDF_ExportSignPublicKey_ECC(void * hSessionHandle,unsigned int uiKeyIndex,ECCrefPublicKey * pucPublicKey)349 int SDF_ExportSignPublicKey_ECC(
350 	void *hSessionHandle,
351 	unsigned int uiKeyIndex,
352 	ECCrefPublicKey *pucPublicKey)
353 {
354 	if (!pucPublicKey)
355 		return SDR_INARGERR;
356 	memcpy(pucPublicKey, eccPublicKeyBuf, sizeof(*pucPublicKey));
357 	return SDR_OK;
358 }
359 
SDF_ExportEncPublicKey_ECC(void * hSessionHandle,unsigned int uiKeyIndex,ECCrefPublicKey * pucPublicKey)360 int SDF_ExportEncPublicKey_ECC(
361 	void *hSessionHandle,
362 	unsigned int uiKeyIndex,
363 	ECCrefPublicKey *pucPublicKey)
364 {
365 	if (!pucPublicKey)
366 		return SDR_INARGERR;
367 	memcpy(pucPublicKey, eccPublicKeyBuf, sizeof(*pucPublicKey));
368 	return SDR_OK;
369 }
370 
SDF_GenerateKeyPair_ECC(void * hSessionHandle,unsigned int uiAlgID,unsigned int uiKeyBits,ECCrefPublicKey * pucPublicKey,ECCrefPrivateKey * pucPrivateKey)371 int SDF_GenerateKeyPair_ECC(
372 	void *hSessionHandle,
373 	unsigned int uiAlgID,
374 	unsigned int  uiKeyBits,
375 	ECCrefPublicKey *pucPublicKey,
376 	ECCrefPrivateKey *pucPrivateKey)
377 {
378 	if (!pucPublicKey || !pucPublicKey)
379 		return SDR_INARGERR;
380 	memcpy(pucPublicKey, eccPublicKeyBuf, sizeof(*pucPublicKey));
381 	memcpy(pucPrivateKey, eccPrivateKeyBuf, sizeof(*pucPrivateKey));
382 	return SDR_OK;
383 }
384 
SDF_GenerateKeyWithIPK_ECC(void * hSessionHandle,unsigned int uiIPKIndex,unsigned int uiKeyBits,ECCCipher * pucKey,void ** phKeyHandle)385 int SDF_GenerateKeyWithIPK_ECC(
386 	void *hSessionHandle,
387 	unsigned int uiIPKIndex,
388 	unsigned int uiKeyBits,
389 	ECCCipher *pucKey,
390 	void **phKeyHandle)
391 {
392 	if (!phKeyHandle || !(*phKeyHandle))
393 		return SDR_INARGERR;
394 	*phKeyHandle = keyHandle;
395 	return SDR_OK;
396 }
397 
SDF_GenerateKeyWithEPK_ECC(void * hSessionHandle,unsigned int uiKeyBits,unsigned int uiAlgID,ECCrefPublicKey * pucPublicKey,ECCCipher * pucKey,void ** phKeyHandle)398 int SDF_GenerateKeyWithEPK_ECC(
399 	void *hSessionHandle,
400 	unsigned int uiKeyBits,
401 	unsigned int uiAlgID,
402 	ECCrefPublicKey *pucPublicKey,
403 	ECCCipher *pucKey,
404 	void **phKeyHandle)
405 {
406 	if (!phKeyHandle || !(*phKeyHandle))
407 		return SDR_INARGERR;
408 	*phKeyHandle = keyHandle;
409 	return SDR_OK;
410 }
411 
SDF_ImportKeyWithISK_ECC(void * hSessionHandle,unsigned int uiISKIndex,ECCCipher * pucKey,void ** phKeyHandle)412 int SDF_ImportKeyWithISK_ECC(
413 	void *hSessionHandle,
414 	unsigned int uiISKIndex,
415 	ECCCipher *pucKey,
416 	void **phKeyHandle)
417 {
418 	if (!phKeyHandle || !(*phKeyHandle))
419 		return SDR_INARGERR;
420 	*phKeyHandle = keyHandle;
421 	return SDR_OK;
422 }
423 
424 /* 6.3.14 */
SDF_GenerateAgreementDataWithECC(void * hSessionHandle,unsigned int uiISKIndex,unsigned int uiKeyBits,unsigned char * pucSponsorID,unsigned int uiSponsorIDLength,ECCrefPublicKey * pucSponsorPublicKey,ECCrefPublicKey * pucSponsorTmpPublicKey,void ** phAgreementHandle)425 int SDF_GenerateAgreementDataWithECC(
426 	void *hSessionHandle,
427 	unsigned int uiISKIndex,
428 	unsigned int uiKeyBits,
429 	unsigned char *pucSponsorID,
430 	unsigned int uiSponsorIDLength,
431 	ECCrefPublicKey *pucSponsorPublicKey,
432 	ECCrefPublicKey *pucSponsorTmpPublicKey,
433 	void **phAgreementHandle)
434 {
435 	// any output public key ?
436 	if (!phAgreementHandle || !(*phAgreementHandle))
437 		return SDR_INARGERR;
438 	*phAgreementHandle = agreementHandle;
439 	return SDR_OK;
440 }
441 
442 /* 6.3.15 */
SDF_GenerateKeyWithECC(void * hSessionHandle,unsigned char * pucResponseID,unsigned int uiResponseIDLength,ECCrefPublicKey * pucResponsePublicKey,ECCrefPublicKey * pucResponseTmpPublicKey,void * hAgreementHandle,void ** phKeyHandle)443 int SDF_GenerateKeyWithECC(
444 	void *hSessionHandle,
445 	unsigned char *pucResponseID,
446 	unsigned int uiResponseIDLength,
447 	ECCrefPublicKey *pucResponsePublicKey,
448 	ECCrefPublicKey *pucResponseTmpPublicKey,
449 	void *hAgreementHandle,
450 	void **phKeyHandle)
451 {
452 	if (!phKeyHandle || !(*phKeyHandle))
453 		return SDR_INARGERR;
454 	*phKeyHandle = keyHandle;
455 	return SDR_OK;
456 }
457 
458 /* 6.3.16 */
SDF_GenerateAgreementDataAndKeyWithECC(void * hSessionHandle,unsigned int uiISKIndex,unsigned int uiKeyBits,unsigned char * pucResponseID,unsigned int uiResponseIDLength,unsigned char * pucSponsorID,unsigned int uiSponsorIDLength,ECCrefPublicKey * pucSponsorPublicKey,ECCrefPublicKey * pucSponsorTmpPublicKey,ECCrefPublicKey * pucResponsePublicKey,ECCrefPublicKey * pucResponseTmpPublicKey,void ** phKeyHandle)459 int SDF_GenerateAgreementDataAndKeyWithECC(
460 	void *hSessionHandle,
461 	unsigned int uiISKIndex,
462 	unsigned int uiKeyBits,
463 	unsigned char *pucResponseID,
464 	unsigned int uiResponseIDLength,
465 	unsigned char *pucSponsorID,
466 	unsigned int uiSponsorIDLength,
467 	ECCrefPublicKey *pucSponsorPublicKey,
468 	ECCrefPublicKey *pucSponsorTmpPublicKey,
469 	ECCrefPublicKey *pucResponsePublicKey,
470 	ECCrefPublicKey *pucResponseTmpPublicKey,
471 	void **phKeyHandle)
472 {
473 	// any output
474 	if (!phKeyHandle || !(*phKeyHandle))
475 		return SDR_INARGERR;
476 	*phKeyHandle = keyHandle;
477 	return SDR_OK;
478 }
479 
SDF_ExchangeDigitEnvelopeBaseOnECC(void * hSessionHandle,unsigned int uiKeyIndex,unsigned int uiAlgID,ECCrefPublicKey * pucPublicKey,ECCCipher * pucEncDataIn,ECCCipher * pucEncDataOut)480 int SDF_ExchangeDigitEnvelopeBaseOnECC(
481 	void *hSessionHandle,
482 	unsigned int uiKeyIndex,
483 	unsigned int uiAlgID,
484 	ECCrefPublicKey *pucPublicKey,
485 	ECCCipher *pucEncDataIn,
486 	ECCCipher *pucEncDataOut)
487 {
488 	return SDR_OK;
489 }
490 
SDF_GenerateKeyWithKEK(void * hSessionHandle,unsigned int uiKeyBits,unsigned int uiAlgID,unsigned int uiKEKIndex,unsigned char * pucKey,unsigned int * puiKeyLength,void ** phKeyHandle)491 int SDF_GenerateKeyWithKEK(
492 	void *hSessionHandle,
493 	unsigned int uiKeyBits,
494 	unsigned int uiAlgID,
495 	unsigned int uiKEKIndex,
496 	unsigned char *pucKey,
497 	unsigned int *puiKeyLength,
498 	void **phKeyHandle)
499 {
500 	if (!phKeyHandle || !(*phKeyHandle))
501 		return SDR_INARGERR;
502 	*phKeyHandle = keyHandle;
503 	return SDR_OK;
504 }
505 
SDF_ImportKeyWithKEK(void * hSessionHandle,unsigned int uiAlgID,unsigned int uiKEKIndex,unsigned char * pucKey,unsigned int uiKeyLength,void ** phKeyHandle)506 int SDF_ImportKeyWithKEK(
507 	void *hSessionHandle,
508 	unsigned int uiAlgID,
509 	unsigned int uiKEKIndex,
510 	unsigned char *pucKey,
511 	unsigned int uiKeyLength,
512 	void **phKeyHandle)
513 {
514 	if (!phKeyHandle || !(*phKeyHandle))
515 		return SDR_INARGERR;
516 	*phKeyHandle = keyHandle;
517 	return SDR_OK;
518 }
519 
SDF_DestroyKey(void * hSessionHandle,void * hKeyHandle)520 int SDF_DestroyKey(
521 	void *hSessionHandle,
522 	void *hKeyHandle)
523 {
524 	return SDR_OK;
525 }
526 
SDF_ExternalPublicKeyOperation_RSA(void * hSessionHandle,RSArefPublicKey * pucPublicKey,unsigned char * pucDataInput,unsigned int uiInputLength,unsigned char * pucDataOutput,unsigned int * puiOutputLength)527 int SDF_ExternalPublicKeyOperation_RSA(
528 	void *hSessionHandle,
529 	RSArefPublicKey *pucPublicKey,
530 	unsigned char *pucDataInput,
531 	unsigned int uiInputLength,
532 	unsigned char *pucDataOutput,
533 	unsigned int *puiOutputLength)
534 {
535 	if (!puiOutputLength)
536 		return SDR_INARGERR;
537 	*puiOutputLength = 2048/8;
538 	return SDR_OK;
539 }
540 
SDF_ExternalPrivateKeyOperation_RSA(void * hSessionHandle,RSArefPrivateKey * pucPrivateKey,unsigned char * pucDataInput,unsigned int uiInputLength,unsigned char * pucDataOutput,unsigned int * puiOutputLength)541 int SDF_ExternalPrivateKeyOperation_RSA(
542 	void *hSessionHandle,
543 	RSArefPrivateKey *pucPrivateKey,
544 	unsigned char *pucDataInput,
545 	unsigned int uiInputLength,
546 	unsigned char *pucDataOutput,
547 	unsigned int *puiOutputLength)
548 {
549 	if (!puiOutputLength)
550 		return SDR_INARGERR;
551 	*puiOutputLength = 2048/8;
552 	return SDR_OK;
553 }
554 
SDF_InternalPrivateKeyOperation_RSA(void * hSessionHandle,unsigned int uiKeyIndex,unsigned char * pucDataInput,unsigned int uiInputLength,unsigned char * pucDataOutput,unsigned int * puiOutputLength)555 int SDF_InternalPrivateKeyOperation_RSA(
556 	void *hSessionHandle,
557 	unsigned int uiKeyIndex,
558 	unsigned char *pucDataInput,
559 	unsigned int uiInputLength,
560 	unsigned char *pucDataOutput,
561 	unsigned int *puiOutputLength)
562 {
563 	if (!puiOutputLength)
564 		return SDR_INARGERR;
565 	*puiOutputLength = 2048/8;
566 	return SDR_OK;
567 }
568 
SDF_ExternalVerify_ECC(void * hSessionHandle,unsigned int uiAlgID,ECCrefPublicKey * pucPublicKey,unsigned char * pucDataInput,unsigned int uiInputLength,ECCSignature * pucSignature)569 int SDF_ExternalVerify_ECC(
570 	void *hSessionHandle,
571 	unsigned int uiAlgID,
572 	ECCrefPublicKey *pucPublicKey,
573 	unsigned char *pucDataInput,
574 	unsigned int uiInputLength,
575 	ECCSignature *pucSignature)
576 {
577 	return SDR_OK;
578 }
579 
SDF_InternalSign_ECC(void * hSessionHandle,unsigned int uiISKIndex,unsigned char * pucData,unsigned int uiDataLength,ECCSignature * pucSignature)580 int SDF_InternalSign_ECC(
581 	void *hSessionHandle,
582 	unsigned int uiISKIndex,
583 	unsigned char *pucData,
584 	unsigned int uiDataLength,
585 	ECCSignature *pucSignature)
586 {
587 	return SDR_OK;
588 }
589 
SDF_InternalVerify_ECC(void * hSessionHandle,unsigned int uiIPKIndex,unsigned char * pucData,unsigned int uiDataLength,ECCSignature * pucSignature)590 int SDF_InternalVerify_ECC(
591 	void *hSessionHandle,
592 	unsigned int uiIPKIndex,
593 	unsigned char *pucData,
594 	unsigned int uiDataLength,
595 	ECCSignature *pucSignature)
596 {
597 	return SDR_OK;
598 }
599 
SDF_ExternalEncrypt_ECC(void * hSessionHandle,unsigned int uiAlgID,ECCrefPublicKey * pucPublicKey,unsigned char * pucData,unsigned int uiDataLength,ECCCipher * pucEncData)600 int SDF_ExternalEncrypt_ECC(
601 	void *hSessionHandle,
602 	unsigned int uiAlgID,
603 	ECCrefPublicKey *pucPublicKey,
604 	unsigned char *pucData,
605 	unsigned int uiDataLength,
606 	ECCCipher *pucEncData)
607 {
608 	if (!pucEncData)
609 		return SDR_INARGERR;
610 	pucEncData->L = uiDataLength;
611 	return SDR_OK;
612 }
613 
SDF_Encrypt(void * hSessionHandle,void * hKeyHandle,unsigned int uiAlgID,unsigned char * pucIV,unsigned char * pucData,unsigned int uiDataLength,unsigned char * pucEncData,unsigned int * puiEncDataLength)614 int SDF_Encrypt(
615 	void *hSessionHandle,
616 	void *hKeyHandle,
617 	unsigned int uiAlgID,
618 	unsigned char *pucIV,
619 	unsigned char *pucData,
620 	unsigned int uiDataLength,
621 	unsigned char *pucEncData,
622 	unsigned int *puiEncDataLength)
623 {
624 	if (!puiEncDataLength)
625 		return SDR_INARGERR;
626 	*puiEncDataLength = uiDataLength;
627 	return SDR_OK;
628 }
629 
SDF_Decrypt(void * hSessionHandle,void * hKeyHandle,unsigned int uiAlgID,unsigned char * pucIV,unsigned char * pucEncData,unsigned int uiEncDataLength,unsigned char * pucData,unsigned int * puiDataLength)630 int SDF_Decrypt(
631 	void *hSessionHandle,
632 	void *hKeyHandle,
633 	unsigned int uiAlgID,
634 	unsigned char *pucIV,
635 	unsigned char *pucEncData,
636 	unsigned int uiEncDataLength,
637 	unsigned char *pucData,
638 	unsigned int *puiDataLength)
639 {
640 	if (!puiDataLength)
641 		return SDR_INARGERR;
642 	*puiDataLength = uiEncDataLength;
643 	return SDR_OK;
644 }
645 
SDF_CalculateMAC(void * hSessionHandle,void * hKeyHandle,unsigned int uiAlgID,unsigned char * pucIV,unsigned char * pucData,unsigned int uiDataLength,unsigned char * pucMAC,unsigned int * puiMACLength)646 int SDF_CalculateMAC(
647 	void *hSessionHandle,
648 	void *hKeyHandle,
649 	unsigned int uiAlgID,
650 	unsigned char *pucIV,
651 	unsigned char *pucData,
652 	unsigned int uiDataLength,
653 	unsigned char *pucMAC,
654 	unsigned int *puiMACLength)
655 {
656 	if (!puiMACLength)
657 		return SDR_INARGERR;
658 	*puiMACLength = 16; /* CBC-MAC length */
659 	return SDR_OK;
660 }
661 
SDF_HashInit(void * hSessionHandle,unsigned int uiAlgID,ECCrefPublicKey * pucPublicKey,unsigned char * pucID,unsigned int uiIDLength)662 int SDF_HashInit(
663 	void *hSessionHandle,
664 	unsigned int uiAlgID,
665 	ECCrefPublicKey *pucPublicKey,
666 	unsigned char *pucID,
667 	unsigned int uiIDLength)
668 {
669 	return SDR_OK;
670 }
671 
SDF_HashUpdate(void * hSessionHandle,unsigned char * pucData,unsigned int uiDataLength)672 int SDF_HashUpdate(
673 	void *hSessionHandle,
674 	unsigned char *pucData,
675 	unsigned int uiDataLength)
676 {
677 	return SDR_OK;
678 }
679 
SDF_HashFinal(void * hSessionHandle,unsigned char * pucHash,unsigned int * puiHashLength)680 int SDF_HashFinal(void *hSessionHandle,
681 	unsigned char *pucHash,
682 	unsigned int *puiHashLength)
683 {
684 	if (!puiHashLength)
685 		return SDR_INARGERR;
686 	*puiHashLength = 32;
687 	return SDR_OK;
688 }
689 
SDF_CreateFile(void * hSessionHandle,unsigned char * pucFileName,unsigned int uiNameLen,unsigned int uiFileSize)690 int SDF_CreateFile(
691 	void *hSessionHandle,
692 	unsigned char *pucFileName,
693 	unsigned int uiNameLen,
694 	unsigned int uiFileSize)
695 {
696 	return SDR_OK;
697 }
698 
SDF_ReadFile(void * hSessionHandle,unsigned char * pucFileName,unsigned int uiNameLen,unsigned int uiOffset,unsigned int * puiReadLength,unsigned char * pucBuffer)699 int SDF_ReadFile(
700 	void *hSessionHandle,
701 	unsigned char *pucFileName,
702 	unsigned int uiNameLen,
703 	unsigned int uiOffset,
704 	unsigned int *puiReadLength,
705 	unsigned char *pucBuffer)
706 {
707 	if (!puiReadLength)
708 		return SDR_INARGERR;
709 	return SDR_OK;
710 }
711 
SDF_WriteFile(void * hSessionHandle,unsigned char * pucFileName,unsigned int uiNameLen,unsigned int uiOffset,unsigned int uiWriteLength,unsigned char * pucBuffer)712 int SDF_WriteFile(
713 	void *hSessionHandle,
714 	unsigned char *pucFileName,
715 	unsigned int uiNameLen,
716 	unsigned int uiOffset,
717 	unsigned int uiWriteLength,
718 	unsigned char *pucBuffer)
719 {
720 	return SDR_OK;
721 }
722 
SDF_DeleteFile(void * hSessionHandle,unsigned char * pucFileName,unsigned int uiNameLen)723 int SDF_DeleteFile(
724 	void *hSessionHandle,
725 	unsigned char *pucFileName,
726 	unsigned int uiNameLen)
727 {
728 	return SDR_OK;
729 }
730