This file is indexed.

/usr/include/polarssl/compat-1.2.h is in libpolarssl-dev 1.3.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/**
 * \file compat-1.2.h
 *
 * \brief Backwards compatibility header for PolarSSL-1.2 from PolarSSL-1.3
 *
 *  Copyright (C) 2006-2013, Brainspark B.V.
 *
 *  This file is part of PolarSSL (http://www.polarssl.org)
 *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
 *
 *  All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
#ifndef POLARSSL_COMPAT_1_2_H
#define POLARSSL_COMPAT_1_2_H

#include "config.h"

// Comment out to disable prototype change warnings
#define SHOW_PROTOTYPE_CHANGE_WARNINGS

#if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
#if defined(__ARMCC_VERSION) && !defined(inline)
#define inline __inline
#endif /* __ARMCC_VERSION */
#endif /* _MSC_VER */

#if defined(_MSC_VER)
// MSVC does not support #warning
#undef SHOW_PROTOTYPE_CHANGE_WARNINGS
#endif

#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "You can disable these warnings by commenting SHOW_PROTOTYPE_CHANGE_WARNINGS in compat-1.2.h"
#endif

#if defined(POLARSSL_SHA256_C)
#define POLARSSL_SHA2_C
#include "sha256.h"

/*
 * SHA-2 -> SHA-256
 */
typedef sha256_context sha2_context;

static inline void sha2_starts( sha256_context *ctx, int is224 ) {
    sha256_starts( ctx, is224 );
}
static inline void sha2_update( sha256_context *ctx, const unsigned char *input,
                         size_t ilen ) {
    sha256_update( ctx, input, ilen );
}
static inline void sha2_finish( sha256_context *ctx, unsigned char output[32] ) {
    sha256_finish( ctx, output );
}
static inline int sha2_file( const char *path, unsigned char output[32], int is224 ) {
    return sha256_file( path, output, is224 );
}
static inline void sha2( const unsigned char *input, size_t ilen,
                  unsigned char output[32], int is224 ) {
    sha256( input, ilen, output, is224 );
}
static inline void sha2_hmac_starts( sha256_context *ctx, const unsigned char *key,
                              size_t keylen, int is224 ) {
    sha256_hmac_starts( ctx, key, keylen, is224 );
}
static inline void sha2_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen ) {
    sha256_hmac_update( ctx, input, ilen );
}
static inline void sha2_hmac_finish( sha256_context *ctx, unsigned char output[32] ) {
    sha256_hmac_finish( ctx, output );
}
static inline void sha2_hmac_reset( sha256_context *ctx ) {
    sha256_hmac_reset( ctx );
}
static inline void sha2_hmac( const unsigned char *key, size_t keylen,
                       const unsigned char *input, size_t ilen,
                       unsigned char output[32], int is224 ) {
    sha256_hmac( key, keylen, input, ilen, output, is224 );
}
static inline int sha2_self_test( int verbose ) {
    return sha256_self_test( verbose );
}
#endif /* POLARSSL_SHA256_C */

#if defined(POLARSSL_SHA512_C)
#define POLARSSL_SHA4_C
#include "sha512.h"

/*
 * SHA-4 -> SHA-512
 */
typedef sha512_context sha4_context;

static inline void sha4_starts( sha512_context *ctx, int is384 ) {
    sha512_starts( ctx, is384 );
}
static inline void sha4_update( sha512_context *ctx, const unsigned char *input,
                         size_t ilen ) {
    sha512_update( ctx, input, ilen );
}
static inline void sha4_finish( sha512_context *ctx, unsigned char output[64] ) {
    sha512_finish( ctx, output );
}
static inline int sha4_file( const char *path, unsigned char output[64], int is384 ) {
    return sha512_file( path, output, is384 );
}
static inline void sha4( const unsigned char *input, size_t ilen,
                  unsigned char output[32], int is384 ) {
    sha512( input, ilen, output, is384 );
}
static inline void sha4_hmac_starts( sha512_context *ctx, const unsigned char *key,
                              size_t keylen, int is384 ) {
    sha512_hmac_starts( ctx, key, keylen, is384 );
}
static inline void sha4_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen ) {
    sha512_hmac_update( ctx, input, ilen );
}
static inline void sha4_hmac_finish( sha512_context *ctx, unsigned char output[64] ) {
    sha512_hmac_finish( ctx, output );
}
static inline void sha4_hmac_reset( sha512_context *ctx ) {
    sha512_hmac_reset( ctx );
}
static inline void sha4_hmac( const unsigned char *key, size_t keylen,
                       const unsigned char *input, size_t ilen,
                       unsigned char output[64], int is384 ) {
    sha512_hmac( key, keylen, input, ilen, output, is384 );
}
static inline int sha4_self_test( int verbose ) {
    return sha512_self_test( verbose );
}
#endif /* POLARSSL_SHA512_C */

#if defined(POLARSSL_CIPHER_C)
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "cipher_reset() prototype changed. Manual change required if used"
#endif
#endif

#if defined(POLARSSL_RSA_C)
#define SIG_RSA_RAW     POLARSSL_MD_NONE
#define SIG_RSA_MD2     POLARSSL_MD_MD2
#define SIG_RSA_MD4     POLARSSL_MD_MD4
#define SIG_RSA_MD5     POLARSSL_MD_MD5
#define SIG_RSA_SHA1    POLARSSL_MD_SHA1
#define SIG_RSA_SHA224  POLARSSL_MD_SHA224
#define SIG_RSA_SHA256  POLARSSL_MD_SHA256
#define SIG_RSA_SHA384  POLARSSL_MD_SHA384
#define SIG_RSA_SHA512  POLARSSL_MD_SHA512
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "rsa_pkcs1_verify() prototype changed. Manual change required if used"
#warning "rsa_pkcs1_decrypt() prototype changed. Manual change required if used"
#endif
#endif

#if defined(POLARSSL_DHM_C)
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "dhm_calc_secret() prototype changed. Manual change required if used"
#endif
#endif

#if defined(POLARSSL_GCM_C)
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "gcm_init() prototype changed. Manual change required if used"
#endif
#endif

#if defined(POLARSSL_SSL_CLI_C)
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
#warning "ssl_set_own_cert() prototype changed. Change to ssl_set_own_cert_rsa(). Manual change required if used"
#endif
#endif

#if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
#include "x509.h"

#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT POLARSSL_ERR_X509_INVALID_FORMAT
#define POLARSSL_ERR_X509_CERT_INVALID_VERSION POLARSSL_ERR_X509_INVALID_VERSION
#define POLARSSL_ERR_X509_CERT_INVALID_ALG POLARSSL_ERR_X509_INVALID_ALG
#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG POLARSSL_ERR_X509_UNKNOWN_SIG_ALG
#define POLARSSL_ERR_X509_CERT_INVALID_NAME POLARSSL_ERR_X509_INVALID_NAME
#define POLARSSL_ERR_X509_CERT_INVALID_DATE POLARSSL_ERR_X509_INVALID_DATE
#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS POLARSSL_ERR_X509_INVALID_EXTENSIONS
#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH POLARSSL_ERR_X509_SIG_MISMATCH
#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE POLARSSL_ERR_X509_INVALID_SIGNATURE
#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL POLARSSL_ERR_X509_INVALID_SERIAL
#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION POLARSSL_ERR_X509_UNKNOWN_VERSION

static inline int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial ) {
    return x509_serial_gets( buf, size, serial );
}
static inline int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn ) {
    return x509_dn_gets( buf, size, dn );
}
static inline int x509parse_time_expired( const x509_time *time ) {
    return x509_time_expired( time );
}
#endif /* POLARSSL_X509_USE_C || POLARSSL_X509_CREATE_C */

#if defined(POLARSSL_X509_CRT_PARSE_C)
#define POLARSSL_X509_PARSE_C
#include "x509_crt.h"
typedef x509_crt x509_cert;

static inline int x509parse_crt_der( x509_cert *chain, const unsigned char *buf,
                              size_t buflen ) {
    return x509_crt_parse_der( chain, buf, buflen );
}
static inline int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ) {
    return x509_crt_parse( chain, buf, buflen );
}
static inline int x509parse_crtfile( x509_cert *chain, const char *path ) {
    return x509_crt_parse_file( chain, path );
}
static inline int x509parse_crtpath( x509_cert *chain, const char *path ) {
    return x509_crt_parse_path( chain, path );
}
static inline int x509parse_cert_info( char *buf, size_t size, const char *prefix,
                                const x509_cert *crt ) {
    return x509_crt_info( buf, size, prefix, crt );
}
static inline int x509parse_verify( x509_cert *crt, x509_cert *trust_ca,
                             x509_crl *ca_crl, const char *cn, int *flags,
                             int (*f_vrfy)(void *, x509_cert *, int, int *),
                             void *p_vrfy ) {
    return x509_crt_verify( crt, trust_ca, ca_crl, cn, flags, f_vrfy, p_vrfy );
}
static inline int x509parse_revoked( const x509_cert *crt, const x509_crl *crl ) {
    return x509_crt_revoked( crt, crl );
}
static inline void x509_free( x509_cert *crt ) {
    x509_crt_free( crt );
}
#endif /* POLARSSL_X509_CRT_PARSE_C */

#if defined(POLARSSL_X509_CRL_PARSE_C)
#define POLARSSL_X509_PARSE_C
#include "x509_crl.h"
static inline int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen ) {
    return x509_crl_parse( chain, buf, buflen );
}
static inline int x509parse_crlfile( x509_crl *chain, const char *path ) {
    return x509_crl_parse_file( chain, path );
}
static inline int x509parse_crl_info( char *buf, size_t size, const char *prefix,
                               const x509_crl *crl ) {
    return x509_crl_info( buf, size, prefix, crl );
}
#endif /* POLARSSL_X509_CRL_PARSE_C */

#if defined(POLARSSL_X509_CSR_PARSE_C)
#define POLARSSL_X509_PARSE_C
#include "x509_csr.h"
static inline int x509parse_csr( x509_csr *csr, const unsigned char *buf, size_t buflen ) {
    return x509_csr_parse( csr, buf, buflen );
}
static inline int x509parse_csrfile( x509_csr *csr, const char *path ) {
    return x509_csr_parse_file( csr, path );
}
static inline int x509parse_csr_info( char *buf, size_t size, const char *prefix,
                               const x509_csr *csr ) {
    return x509_csr_info( buf, size, prefix, csr );
}
#endif /* POLARSSL_X509_CSR_PARSE_C */

#if defined(POLARSSL_SSL_TLS_C)
#include "ssl_ciphersuites.h"

#define ssl_default_ciphersuites ssl_list_ciphersuites()
#endif

#if defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_RSA_C)
#include "rsa.h"
#include "pk.h"

#define POLARSSL_ERR_X509_PASSWORD_MISMATCH POLARSSL_ERR_PK_PASSWORD_MISMATCH
#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT POLARSSL_ERR_PK_KEY_INVALID_FORMAT
#define POLARSSL_ERR_X509_UNKNOWN_PK_ALG POLARSSL_ERR_PK_UNKNOWN_PK_ALG
#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY POLARSSL_ERR_PK_INVALID_PUBKEY

#if defined(POLARSSL_FS_IO)
static inline int x509parse_keyfile( rsa_context *rsa, const char *path,
                              const char *pwd ) {
    int ret;
    pk_context pk;
    pk_init( &pk );
    ret = pk_parse_keyfile( &pk, path, pwd );
    if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
        ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
    if( ret == 0 )
        rsa_copy( rsa, pk_rsa( pk ) );
    else
        rsa_free( rsa );
    pk_free( &pk );
    return( ret );
}
static inline int x509parse_public_keyfile( rsa_context *rsa, const char *path ) {
    int ret;
    pk_context pk;
    pk_init( &pk );
    ret = pk_parse_public_keyfile( &pk, path );
    if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
        ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
    if( ret == 0 )
        rsa_copy( rsa, pk_rsa( pk ) );
    else
        rsa_free( rsa );
    pk_free( &pk );
    return( ret );
}
#endif /* POLARSSL_FS_IO */

static inline int x509parse_key( rsa_context *rsa, const unsigned char *key,
                          size_t keylen,
                          const unsigned char *pwd, size_t pwdlen ) {
    int ret;
    pk_context pk;
    pk_init( &pk );
    ret = pk_parse_key( &pk, key, keylen, pwd, pwdlen );
    if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
        ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
    if( ret == 0 )
        rsa_copy( rsa, pk_rsa( pk ) );
    else
        rsa_free( rsa );
    pk_free( &pk );
    return( ret );
}

static inline int x509parse_public_key( rsa_context *rsa,
                                 const unsigned char *key, size_t keylen )
{
    int ret;
    pk_context pk;
    pk_init( &pk );
    ret = pk_parse_public_key( &pk, key, keylen );
    if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
        ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
    if( ret == 0 )
        rsa_copy( rsa, pk_rsa( pk ) );
    else
        rsa_free( rsa );
    pk_free( &pk );
    return( ret );
}
#endif /* POLARSSL_PK_PARSE_C && POLARSSL_RSA_C */

#if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_RSA_C)
#include "pk.h"
static inline int x509_write_pubkey_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
    int ret;
    pk_context ctx;
    if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
    if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
    ret = pk_write_pubkey_der( &ctx, buf, len );
    pk_free( &ctx );
    return( ret );
}
static inline int x509_write_key_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
    int ret;
    pk_context ctx;
    if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
    if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
    ret = pk_write_key_der( &ctx, buf, len );
    pk_free( &ctx );
    return( ret );
}
#endif /* POLARSSL_PK_WRITE_C && POLARSSL_RSA_C */
#endif /* compat-1.2.h */