@@ -43,7 +43,7 @@ typedef _Return_type_success_(return >= 0) int SCOSSL_RETURNLENGTH; // For funct
43
43
// pointer before using it with SymCrypt.
44
44
//
45
45
// In the SCOSSL provider, it is our responsibility to perform the allocation and free ourselves.
46
- // Here we allocate SYMCRYPT_ALIGN_VALUE extra bytes, and store the offset into our allocation in the byte before the aligned
46
+ // Here we allocate SYMCRYPT_ALIGN_VALUE extra bytes, and store the offset into our allocation in the byte before the aligned
47
47
// pointer we use in SymCrypt. On free, we look at the byte before the aligned pointer we have been using, to determine the start
48
48
// of the allocation and free it correctly.
49
49
//
@@ -91,62 +91,94 @@ void scossl_destroy_logging();
91
91
92
92
// SCOSSL function codes
93
93
typedef enum {
94
+ // ScosslCommon
94
95
SCOSSL_ERR_F_ENUM_START = 100 ,
95
96
SCOSSL_ERR_F_AES_CCM_CIPHER ,
96
- SCOSSL_ERR_F_AES_CCM_CTRL ,
97
+ SCOSSL_ERR_F_AES_CCM_SET_IV_FIXED ,
98
+ SCOSSL_ERR_F_AES_CCM_SET_IV_LEN ,
99
+ SCOSSL_ERR_F_AES_CCM_SET_TLS1_AAD ,
97
100
SCOSSL_ERR_F_AES_CCM_TLS ,
98
- SCOSSL_ERR_F_AES_GCM_CTRL ,
101
+ SCOSSL_ERR_F_AES_GCM_CIPHER ,
102
+ SCOSSL_ERR_F_AES_GCM_IV_GEN ,
103
+ SCOSSL_ERR_F_AES_GCM_SET_IV_FIXED ,
104
+ SCOSSL_ERR_F_AES_GCM_SET_IV_INV ,
105
+ SCOSSL_ERR_F_AES_GCM_SET_IV_LEN ,
106
+ SCOSSL_ERR_F_AES_GCM_SET_TLS1_AAD ,
99
107
SCOSSL_ERR_F_AES_GCM_TLS ,
100
- SCOSSL_ERR_F_AES_XTS_CIPHER ,
101
- SCOSSL_ERR_F_AES_XTS_CTRL ,
102
- SCOSSL_ERR_F_DH_COMPUTE_KEY ,
103
- SCOSSL_ERR_F_DH_GENERATE_KEY ,
104
108
SCOSSL_ERR_F_DH_GENERATE_KEYPAIR ,
109
+ SCOSSL_ERR_F_DH_GET_GROUP_BY_NID ,
105
110
SCOSSL_ERR_F_DH_IMPORT_KEYPAIR ,
106
- SCOSSL_ERR_F_DIGESTS ,
107
- SCOSSL_ERR_F_ECC_GENERATE_KEYPAIR ,
108
- SCOSSL_ERR_F_ECC_IMPORT_KEYPAIR ,
111
+ SCOSSL_ERR_F_ECC_GROUP_TO_SYMCRYPT_CURVE ,
112
+ SCOSSL_ERR_F_ECC_POINT_TO_PUBKEY ,
109
113
SCOSSL_ERR_F_ECDSA_APPLY_DER ,
110
114
SCOSSL_ERR_F_ECDSA_DER_CHECK_TAG_AND_GET_VALUE_AND_LENGTH ,
111
115
SCOSSL_ERR_F_ECDSA_REMOVE_DER ,
112
- SCOSSL_ERR_F_ECKEY_COMPUTE_KEY ,
113
- SCOSSL_ERR_F_ECKEY_KEYGEN ,
114
- SCOSSL_ERR_F_ECKEY_SIGN ,
115
- SCOSSL_ERR_F_ECKEY_SIGN_SETUP ,
116
- SCOSSL_ERR_F_ECKEY_SIGN_SIG ,
117
- SCOSSL_ERR_F_ECKEY_VERIFY ,
118
- SCOSSL_ERR_F_ECKEY_VERIFY_SIG ,
119
- SCOSSL_ERR_F_GET_DH_CONTEXT_EX ,
120
- SCOSSL_ERR_F_GET_ECC_CONTEXT_EX ,
116
+ SCOSSL_ERR_F_ECDSA_SIGN ,
117
+ SCOSSL_ERR_F_ECDSA_VERIFY ,
121
118
SCOSSL_ERR_F_GET_SYMCRYPT_HASH_ALGORITHM ,
122
119
SCOSSL_ERR_F_GET_SYMCRYPT_MAC_ALGORITHM ,
123
- SCOSSL_ERR_F_HKDF_CTRL ,
124
120
SCOSSL_ERR_F_HKDF_DERIVE ,
125
- SCOSSL_ERR_F_HKDF_INIT ,
126
- SCOSSL_ERR_F_INITIALIZE_RSA_KEY ,
127
- SCOSSL_ERR_F_PKEY_METHODS ,
128
- SCOSSL_ERR_F_PKEY_RSA_SIGN ,
129
- SCOSSL_ERR_F_PKEY_RSA_VERIFY ,
130
- SCOSSL_ERR_F_RSA_INIT ,
131
- SCOSSL_ERR_F_RSA_KEYGEN ,
132
- SCOSSL_ERR_F_RSA_PRIV_DEC ,
133
- SCOSSL_ERR_F_RSA_PRIV_ENC ,
134
- SCOSSL_ERR_F_RSA_PUB_DEC ,
135
- SCOSSL_ERR_F_RSA_PUB_ENC ,
136
- SCOSSL_ERR_F_RSA_SIGN ,
137
- SCOSSL_ERR_F_RSA_VERIFY ,
121
+ SCOSSL_ERR_F_MAC_INIT ,
122
+ SCOSSL_ERR_F_MAC_SET_HMAC_MD ,
123
+ SCOSSL_ERR_F_RSA_DECRYPT ,
124
+ SCOSSL_ERR_F_RSA_ENCRYPT ,
125
+ SCOSSL_ERR_F_RSA_EXPORT_KEY ,
126
+ SCOSSL_ERR_F_RSA_NEW_EXPORT_PARAMS ,
127
+ SCOSSL_ERR_F_RSA_PKCS1_SIGN ,
128
+ SCOSSL_ERR_F_RSA_PKCS1_VERIFY ,
138
129
SCOSSL_ERR_F_RSAPSS_SIGN ,
139
130
SCOSSL_ERR_F_RSAPSS_VERIFY ,
140
- SCOSSL_ERR_F_TLS1PRF_CTRL ,
141
- SCOSSL_ERR_F_TLS1PRF_DERIVE ,
142
- SCOSSL_ERR_F_TLS1PRF_INIT ,
143
- SCOSSL_ERR_F_HMAC_INIT ,
144
- SCOSSL_ERR_F_HMAC_CTRL ,
145
- SCOSSL_ERR_F_HMAC_CTRL_STR ,
146
- SCOSSL_ERR_F_SSHKDF_NEW ,
147
- SCOSSL_ERR_F_SSHKDF_CTRL ,
148
- SCOSSL_ERR_F_SSHKDF_CTRL_STR ,
149
131
SCOSSL_ERR_F_SSHKDF_DERIVE ,
132
+ SCOSSL_ERR_F_TLS1PRF_DERIVE ,
133
+ // SymCryptEngine
134
+ SCOSSL_ERR_F_ENG_AES_CCM_CTRL ,
135
+ SCOSSL_ERR_F_ENG_AES_GCM_CTRL ,
136
+ SCOSSL_ERR_F_ENG_AES_XTS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EY_RSA_VERIFY ,
165
+ SCOSSL_ERR_F_ENG_PKEY_RSAPSS_VERIFY ,
166
+ SCOSSL_ERR_F_ENG_RSA_INIT ,
167
+ SCOSSL_ERR_F_ENG_RSA_KEYGEN ,
168
+ SCOSSL_ERR_F_ENG_RSA_PRIV_DEC ,
169
+ SCOSSL_ERR_F_ENG_RSA_PRIV_ENC ,
170
+ SCOSSL_ERR_F_ENG_RSA_PUB_DEC ,
171
+ SCOSSL_ERR_F_ENG_RSA_PUB_ENC ,
172
+ SCOSSL_ERR_F_ENG_RSA_SIGN ,
173
+ SCOSSL_ERR_F_ENG_RSA_VERIFY ,
174
+ SCOSSL_ERR_F_ENG_RSAPSS_SIGN ,
175
+ SCOSSL_ERR_F_ENG_RSAPSS_VERIFY ,
176
+ SCOSSL_ERR_F_ENG_SSHKDF_CTRL ,
177
+ SCOSSL_ERR_F_ENG_SSHKDF_CTRL_STR ,
178
+ SCOSSL_ERR_F_ENG_SSHKDF_DERIVE ,
179
+ SCOSSL_ERR_F_ENG_SSHKDF_NEW ,
180
+ SCOSSL_ERR_F_ENG_TLS1PRF_CTRL ,
181
+ SCOSSL_ERR_F_ENG_TLS1PRF_INIT ,
150
182
SCOSSL_ERR_F_ENUM_END
151
183
} SCOSSL_ERR_FUNC ;
152
184
@@ -158,6 +190,7 @@ typedef enum {
158
190
SCOSSL_ERR_R_NOT_FIPS_ALGORITHM ,
159
191
SCOSSL_ERR_R_OPENSSL_FALLBACK ,
160
192
SCOSSL_ERR_R_SYMCRYPT_FAILURE ,
193
+ SCOSSL_ERR_R_KEYSINUSE_FAILURE ,
161
194
SCOSSL_ERR_R_ENUM_END
162
195
} SCOSSL_ERR_REASON ;
163
196
@@ -179,19 +212,9 @@ void _scossl_log_bytes(
179
212
int len ,
180
213
const char * format , ...);
181
214
182
- void _scossl_log_bignum (
183
- int trace_level ,
184
- SCOSSL_ERR_FUNC func_code ,
185
- SCOSSL_ERR_REASON reason_code ,
186
- const char * file ,
187
- int line ,
188
- char * description ,
189
- BIGNUM * bn );
190
-
191
215
void _scossl_log_SYMCRYPT_ERROR (
192
216
int trace_level ,
193
217
SCOSSL_ERR_FUNC func_code ,
194
- SCOSSL_ERR_REASON reason_code ,
195
218
const char * file ,
196
219
int line ,
197
220
char * description ,
@@ -211,26 +234,18 @@ void _scossl_log_SYMCRYPT_ERROR(
211
234
#define SCOSSL_LOG_BYTES_INFO (func_code , reason_code , description , s , len ) \
212
235
_scossl_log_bytes(SCOSSL_LOG_LEVEL_INFO, func_code, reason_code, __FILE__, __LINE__, (const char*) s, len, description)
213
236
214
- #define SCOSSL_LOG_BIGNUM_DEBUG (func_code , reason_code , description , bn ) \
215
- _scossl_log_bignum(SCOSSL_LOG_LEVEL_DEBUG, func_code, reason_code, __FILE__, __LINE__, description, bn)
216
-
217
- #define SCOSSL_LOG_BIGNUM_INFO (func_code , reason_code , description , s , len ) \
218
- _scossl_log_bignum(SCOSSL_LOG_LEVEL_INFO, func_code, reason_code, __FILE__, __LINE__, description, bn)
237
+ #define SCOSSL_LOG_SYMCRYPT_DEBUG (func_code , description , scError ) \
238
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_DEBUG, func_code, __FILE__, __LINE__, description, scError)
219
239
220
- #define SCOSSL_LOG_SYMCRYPT_DEBUG (func_code , reason_code , description , scError ) \
221
- _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_DEBUG, func_code, reason_code, __FILE__, __LINE__, description, scError)
222
-
223
- #define SCOSSL_LOG_SYMCRYPT_INFO (func_code , reason_code , description , scError ) \
224
- _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_INFO, func_code, reason_code, __FILE__, __LINE__, description, scError)
240
+ #define SCOSSL_LOG_SYMCRYPT_INFO (func_code , description , scError ) \
241
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_INFO, func_code, __FILE__, __LINE__, description, scError)
225
242
#else
226
243
#define SCOSSL_LOG_DEBUG (func_code , reason_code , ...)
227
244
#define SCOSSL_LOG_INFO (func_code , reason_code , ...)
228
245
#define SCOSSL_LOG_BYTES_DEBUG (func_code , reason_code , description , s , len )
229
246
#define SCOSSL_LOG_BYTES_INFO (func_code , reason_code , description , s , len )
230
- #define SCOSSL_LOG_BIGNUM_DEBUG (func_code , reason_code , description , bn )
231
- #define SCOSSL_LOG_BIGNUM_INFO (func_code , reason_code , description , s , len )
232
- #define SCOSSL_LOG_SYMCRYPT_DEBUG (func_code , reason_code , description , scError )
233
- #define SCOSSL_LOG_SYMCRYPT_INFO (func_code , reason_code , description , scError )
247
+ #define SCOSSL_LOG_SYMCRYPT_DEBUG (func_code , description , scError )
248
+ #define SCOSSL_LOG_SYMCRYPT_INFO (func_code , description , scError )
234
249
#endif
235
250
236
251
#define SCOSSL_LOG_ERROR (func_code , reason_code , ...) \
@@ -239,11 +254,48 @@ void _scossl_log_SYMCRYPT_ERROR(
239
254
#define SCOSSL_LOG_BYTES_ERROR (func_code , reason_code , description , s , len ) \
240
255
_scossl_log_bytes(SCOSSL_LOG_LEVEL_ERROR, func_code, reason_code, __FILE__, __LINE__, (const char*) s, len, description)
241
256
242
- #define SCOSSL_LOG_BIGNUM_ERROR (func_code , reason_code , description , s , len ) \
243
- _scossl_log_bignum(SCOSSL_LOG_LEVEL_ERROR, func_code, reason_code, __FILE__, __LINE__, description, bn)
257
+ #define SCOSSL_LOG_SYMCRYPT_ERROR (func_code , description , scError ) \
258
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_ERROR, func_code, __FILE__, __LINE__, description, scError)
259
+
260
+ #if OPENSSL_API_LEVEL >= 30000
261
+ // Enable debug and info messages in debug builds, but compile them out in release builds
262
+ #if DBG
263
+ #define SCOSSL_PROV_LOG_DEBUG (reason_code , ...) \
264
+ _scossl_log(SCOSSL_LOG_LEVEL_DEBUG, 0, reason_code, __FILE__, __LINE__, __VA_ARGS__)
265
+
266
+ #define SCOSSL_PROV_LOG_INFO (reason_code , ...) \
267
+ _scossl_log(SCOSSL_LOG_LEVEL_INFO, 0, reason_code, __FILE__, __LINE__, __VA_ARGS__)
268
+
269
+ #define SCOSSL_PROV_LOG_BYTES_DEBUG (reason_code , description , s , len ) \
270
+ _scossl_log_bytes(SCOSSL_LOG_LEVEL_DEBUG, 0, reason_code, __FILE__, __LINE__, (const char*) s, len, description)
271
+
272
+ #define SCOSSL_PROV_LOG_BYTES_INFO (reason_code , description , s , len ) \
273
+ _scossl_log_bytes(SCOSSL_LOG_LEVEL_INFO, 0, reason_code, __FILE__, __LINE__, (const char*) s, len, description)
274
+
275
+ #define SCOSSL_PROV_LOG_SYMCRYPT_DEBUG (description , scError ) \
276
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_DEBUG, 0, __FILE__, __LINE__, description, scError)
244
277
245
- #define SCOSSL_LOG_SYMCRYPT_ERROR (func_code , reason_code , description , scError ) \
246
- _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_ERROR, func_code, reason_code, __FILE__, __LINE__, description, scError)
278
+ #define SCOSSL_PROV_LOG_SYMCRYPT_INFO (description , scError ) \
279
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_INFO, 0, __FILE__, __LINE__, description, scError)
280
+ #else
281
+ #define SCOSSL_PROV_LOG_DEBUG (reason_code , ...)
282
+ #define SCOSSL_PROV_LOG_INFO (reason_code , ...)
283
+ #define SCOSSL_PROV_LOG_BYTES_DEBUG (reason_code , description , s , len )
284
+ #define SCOSSL_PROV_LOG_BYTES_INFO (reason_code , description , s , len )
285
+ #define SCOSSL_PROV_LOG_SYMCRYPT_DEBUG (description , scError )
286
+ #define SCOSSL_PROV_LOG_SYMCRYPT_INFO (description , scError )
287
+ #endif
288
+
289
+ #define SCOSSL_PROV_LOG_ERROR (reason_code , ...) \
290
+ _scossl_log(SCOSSL_LOG_LEVEL_ERROR, 0, reason_code, __FILE__, __LINE__, __VA_ARGS__)
291
+
292
+ #define SCOSSL_PROV_LOG_BYTES_ERROR (reason_code , description , s , len ) \
293
+ _scossl_log_bytes(SCOSSL_LOG_LEVEL_ERROR, 0, reason_code, __FILE__, __LINE__, (const char*) s, len, description)
294
+
295
+ #define SCOSSL_PROV_LOG_SYMCRYPT_ERROR (description , scError ) \
296
+ _scossl_log_SYMCRYPT_ERROR(SCOSSL_LOG_LEVEL_ERROR, 0, __FILE__, __LINE__, description, scError)
297
+
298
+ #endif
247
299
248
300
//
249
301
// Common helper functions
0 commit comments