@@ -82,9 +82,8 @@ go_hash_sum(GO_EVP_MD_CTX_PTR ctx, GO_EVP_MD_CTX_PTR ctx2, unsigned char *out)
82
82
return go_openssl_EVP_DigestFinal (ctx2 , out , NULL );
83
83
}
84
84
85
- // These wrappers allocate length variables on the C stack to avoid having to pass a pointer from Go, which would escape to the heap.
85
+ // These wrappers allocate out_len on the C stack to avoid having to pass a pointer from Go, which would escape to the heap.
86
86
// Use them only in situations where the output length can be safely discarded.
87
-
88
87
static inline int
89
88
go_openssl_EVP_EncryptUpdate_wrapper (GO_EVP_CIPHER_CTX_PTR ctx , unsigned char * out , const unsigned char * in , int in_len )
90
89
{
@@ -106,18 +105,6 @@ go_openssl_EVP_CipherUpdate_wrapper(GO_EVP_CIPHER_CTX_PTR ctx, unsigned char *ou
106
105
return go_openssl_EVP_CipherUpdate (ctx , out , & len , in , in_len );
107
106
}
108
107
109
- static inline int
110
- go_openssl_EVP_PKEY_get_raw_public_key_wrapper (const GO_EVP_PKEY_PTR pkey , unsigned char * pub , size_t len )
111
- {
112
- return go_openssl_EVP_PKEY_get_raw_public_key (pkey , pub , & len );
113
- }
114
-
115
- static inline int
116
- go_openssl_EVP_PKEY_get_raw_private_key_wrapper (const GO_EVP_PKEY_PTR pkey , unsigned char * priv , size_t len )
117
- {
118
- return go_openssl_EVP_PKEY_get_raw_private_key (pkey , priv , & len );
119
- }
120
-
121
108
// These wrappers also allocate length variables on the C stack to avoid escape to the heap, but do return the result.
122
109
// A struct is returned that contains multiple return values instead of OpenSSL's approach of using pointers.
123
110
@@ -135,6 +122,28 @@ go_openssl_EVP_PKEY_derive_wrapper(GO_EVP_PKEY_CTX_PTR ctx, unsigned char *key,
135
122
return r ;
136
123
}
137
124
125
+ typedef struct
126
+ {
127
+ int result ;
128
+ size_t len ;
129
+ } go_openssl_EVP_PKEY_get_raw_key_out ;
130
+
131
+ static inline go_openssl_EVP_PKEY_get_raw_key_out
132
+ go_openssl_EVP_PKEY_get_raw_public_key_wrapper (const GO_EVP_PKEY_PTR pkey , unsigned char * pub , size_t len )
133
+ {
134
+ go_openssl_EVP_PKEY_get_raw_key_out r = {0 , len };
135
+ r .result = go_openssl_EVP_PKEY_get_raw_public_key (pkey , pub , & r .len );
136
+ return r ;
137
+ }
138
+
139
+ static inline go_openssl_EVP_PKEY_get_raw_key_out
140
+ go_openssl_EVP_PKEY_get_raw_private_key_wrapper (const GO_EVP_PKEY_PTR pkey , unsigned char * priv , size_t len )
141
+ {
142
+ go_openssl_EVP_PKEY_get_raw_key_out r = {0 , len };
143
+ r .result = go_openssl_EVP_PKEY_get_raw_private_key (pkey , priv , & r .len );
144
+ return r ;
145
+ }
146
+
138
147
typedef struct
139
148
{
140
149
int result ;
0 commit comments