Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: openssl/crypto/evp/evp.h

Issue 59083010: third_party/openssl: add ChaCha20+Poly1305 support. Base URL: https://chromium.googlesource.com/chromium/deps/openssl.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « openssl/crypto/evp/e_chacha20poly1305.c ('k') | openssl/crypto/evp/evp_aead.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/evp/evp.h */ 1 /* crypto/evp/evp.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 1236
1237 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, 1237 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
1238 int (*derive_init)(EVP_PKEY_CTX *ctx), 1238 int (*derive_init)(EVP_PKEY_CTX *ctx),
1239 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); 1239 int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));
1240 1240
1241 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, 1241 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
1242 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), 1242 int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
1243 int (*ctrl_str)(EVP_PKEY_CTX *ctx, 1243 int (*ctrl_str)(EVP_PKEY_CTX *ctx,
1244 const char *type, const char *value)); 1244 const char *type, const char *value));
1245 1245
1246 /* Authenticated Encryption with Additional Data.
1247 *
1248 * AEAD couples confidentiality and integrity in a single primtive. AEAD
1249 * algorithms take a key and then can seal and open individual messages. Each
1250 * message has a unique, per-message nonce and, optionally, additional data
1251 * which is authenticated but not included in the output. */
1252
1253 struct evp_aead_st;
1254 typedef struct evp_aead_st EVP_AEAD;
1255
1256 #ifndef OPENSSL_NO_AES
1257 /* EVP_aes_128_gcm is AES-128 in Galois Counter Mode. */
1258 const EVP_AEAD *EVP_aead_aes_128_gcm(void);
1259 #endif
1260
1261 #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
1262 /* EVP_aead_chacha20_poly1305 is ChaCha20 with a Poly1305 authenticator. */
1263 const EVP_AEAD *EVP_aead_chacha20_poly1305(void);
1264 #endif
1265
1266 /* EVP_AEAD_key_length returns the length, in bytes, of the keys used by
1267 * |aead|. */
1268 size_t EVP_AEAD_key_length(const EVP_AEAD *aead);
1269
1270 /* EVP_AEAD_nonce_length returns the length, in bytes, of the per-message nonce
1271 * for |aead|. */
1272 size_t EVP_AEAD_nonce_length(const EVP_AEAD *aead);
1273
1274 /* EVP_AEAD_max_overhead returns the maximum number of additional bytes added
1275 * by the act of sealing data with |aead|. */
1276 size_t EVP_AEAD_max_overhead(const EVP_AEAD *aead);
1277
1278 /* EVP_AEAD_max_tag_len returns the maximum tag length when using |aead|. This
1279 * is the largest value that can be passed as |tag_len| to
1280 * |EVP_AEAD_CTX_init|. */
1281 size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead);
1282
1283 /* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key
1284 * and message-independent IV. */
1285 typedef struct evp_aead_ctx_st {
1286 const EVP_AEAD *aead;
1287 /* aead_state is an opaque pointer to whatever state the AEAD needs to
1288 * maintain. */
1289 void *aead_state;
1290 } EVP_AEAD_CTX;
1291
1292 #define EVP_AEAD_DEFAULT_TAG_LENGTH 0
1293
1294 /* EVP_AEAD_init initializes |ctx| for the given AEAD algorithm from |impl|.
1295 * The |impl| argument may be NULL to choose the default implementation.
1296 * Authentication tags may be truncated by passing a size as |tag_len|. A
1297 * |tag_len| of zero indicates the default tag length and this is defined as
1298 * EVP_AEAD_DEFAULT_TAG_LENGTH for readability.
1299 * Returns 1 on success. Otherwise returns 0 and pushes to the error stack. */
1300 int EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead,
1301 const unsigned char *key, size_t key_len,
1302 size_t tag_len, ENGINE *impl);
1303
1304 /* EVP_AEAD_CTX_cleanup frees any data allocated by |ctx|. */
1305 void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx);
1306
1307 /* EVP_AEAD_CTX_seal encrypts and authenticates |in_len| bytes from |in| and
1308 * authenticates |ad_len| bytes from |ad| and writes the result to |out|,
1309 * returning the number of bytes written, or -1 on error.
1310 *
1311 * This function may be called (with the same EVP_AEAD_CTX) concurrently with
1312 * itself or EVP_AEAD_CTX_open.
1313 *
1314 * At most |max_out_len| bytes are written to |out| and, in order to ensure
1315 * success, |max_out_len| should be |in_len| plus the result of
1316 * EVP_AEAD_overhead.
1317 *
1318 * The length of |nonce|, |nonce_len|, must be equal to the result of
1319 * EVP_AEAD_nonce_length for this AEAD.
1320 *
1321 * EVP_AEAD_CTX_seal never results in a partial output. If |max_out_len| is
1322 * insufficient, -1 will be returned.
1323 *
1324 * If |in| and |out| alias then |out| must be <= |in|. */
1325 ssize_t EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx,
1326 unsigned char *out, size_t max_out_len,
1327 const unsigned char *nonce, size_t nonce_len,
1328 const unsigned char *in, size_t in_len,
1329 const unsigned char *ad, size_t ad_len);
1330
1331 /* EVP_AEAD_CTX_open authenticates |in_len| bytes from |in| and |ad_len| bytes
1332 * from |ad| and decrypts at most |in_len| bytes into |out|. It returns the
1333 * number of bytes written, or -1 on error.
1334 *
1335 * This function may be called (with the same EVP_AEAD_CTX) concurrently with
1336 * itself or EVP_AEAD_CTX_seal.
1337 *
1338 * At most |in_len| bytes are written to |out|. In order to ensure success,
1339 * |max_out_len| should be at least |in_len|.
1340 *
1341 * The length of |nonce|, |nonce_len|, must be equal to the result of
1342 * EVP_AEAD_nonce_length for this AEAD.
1343 *
1344 * EVP_AEAD_CTX_open never results in a partial output. If |max_out_len| is
1345 * insufficient, -1 will be returned.
1346 *
1347 * If |in| and |out| alias then |out| must be <= |in|. */
1348 ssize_t EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx,
1349 unsigned char *out, size_t max_out_len,
1350 const unsigned char *nonce, size_t nonce_len,
1351 const unsigned char *in, size_t in_len,
1352 const unsigned char *ad, size_t ad_len);
1353
1246 void EVP_add_alg_module(void); 1354 void EVP_add_alg_module(void);
1247 1355
1248 /* BEGIN ERROR CODES */ 1356 /* BEGIN ERROR CODES */
1249 /* The following lines are auto generated by the script mkerr.pl. Any changes 1357 /* The following lines are auto generated by the script mkerr.pl. Any changes
1250 * made after this point may be overwritten when the script is next run. 1358 * made after this point may be overwritten when the script is next run.
1251 */ 1359 */
1252 void ERR_load_EVP_strings(void); 1360 void ERR_load_EVP_strings(void);
1253 1361
1254 /* Error codes for the EVP functions. */ 1362 /* Error codes for the EVP functions. */
1255 1363
1256 /* Function codes. */ 1364 /* Function codes. */
1365 #define EVP_F_AEAD_AES_128_GCM_INIT 183
1366 #define EVP_F_AEAD_AES_128_GCM_OPEN 181
1367 #define EVP_F_AEAD_AES_128_GCM_SEAL 182
1368 #define EVP_F_AEAD_CHACHA20_POLY1305_INIT 187
1369 #define EVP_F_AEAD_CHACHA20_POLY1305_OPEN 184
1370 #define EVP_F_AEAD_CHACHA20_POLY1305_SEAL 183
1371 #define EVP_F_AEAD_CTX_OPEN 185
1372 #define EVP_F_AEAD_CTX_SEAL 186
1257 #define EVP_F_AESNI_INIT_KEY 165 1373 #define EVP_F_AESNI_INIT_KEY 165
1258 #define EVP_F_AESNI_XTS_CIPHER 176 1374 #define EVP_F_AESNI_XTS_CIPHER 176
1259 #define EVP_F_AES_INIT_KEY 133 1375 #define EVP_F_AES_INIT_KEY 133
1260 #define EVP_F_AES_XTS 172 1376 #define EVP_F_AES_XTS 172
1261 #define EVP_F_AES_XTS_CIPHER 175 1377 #define EVP_F_AES_XTS_CIPHER 175
1262 #define EVP_F_ALG_MODULE_INIT 177 1378 #define EVP_F_ALG_MODULE_INIT 177
1263 #define EVP_F_CAMELLIA_INIT_KEY 159 1379 #define EVP_F_CAMELLIA_INIT_KEY 159
1264 #define EVP_F_CMAC_INIT 173 1380 #define EVP_F_CMAC_INIT 173
1265 #define EVP_F_D2I_PKEY 100 1381 #define EVP_F_D2I_PKEY 100
1266 #define EVP_F_DO_SIGVER_INIT 161 1382 #define EVP_F_DO_SIGVER_INIT 161
1267 #define EVP_F_DSAPKEY2PKCS8 134 1383 #define EVP_F_DSAPKEY2PKCS8 134
1268 #define EVP_F_DSA_PKEY2PKCS8 135 1384 #define EVP_F_DSA_PKEY2PKCS8 135
1269 #define EVP_F_ECDSA_PKEY2PKCS8 129 1385 #define EVP_F_ECDSA_PKEY2PKCS8 129
1270 #define EVP_F_ECKEY_PKEY2PKCS8 132 1386 #define EVP_F_ECKEY_PKEY2PKCS8 132
1387 #define EVP_F_EVP_AEAD_CTX_INIT 180
1271 #define EVP_F_EVP_CIPHERINIT_EX 123 1388 #define EVP_F_EVP_CIPHERINIT_EX 123
1272 #define EVP_F_EVP_CIPHER_CTX_COPY 163 1389 #define EVP_F_EVP_CIPHER_CTX_COPY 163
1273 #define EVP_F_EVP_CIPHER_CTX_CTRL 124 1390 #define EVP_F_EVP_CIPHER_CTX_CTRL 124
1274 #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 1391 #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
1275 #define EVP_F_EVP_DECRYPTFINAL_EX 101 1392 #define EVP_F_EVP_DECRYPTFINAL_EX 101
1276 #define EVP_F_EVP_DIGESTINIT_EX 128 1393 #define EVP_F_EVP_DIGESTINIT_EX 128
1277 #define EVP_F_EVP_ENCRYPTFINAL_EX 127 1394 #define EVP_F_EVP_ENCRYPTFINAL_EX 127
1278 #define EVP_F_EVP_MD_CTX_COPY_EX 110 1395 #define EVP_F_EVP_MD_CTX_COPY_EX 110
1279 #define EVP_F_EVP_MD_SIZE 162 1396 #define EVP_F_EVP_MD_SIZE 162
1280 #define EVP_F_EVP_OPENINIT 102 1397 #define EVP_F_EVP_OPENINIT 102
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 #define EVP_R_NO_CIPHER_SET 131 1493 #define EVP_R_NO_CIPHER_SET 131
1377 #define EVP_R_NO_DEFAULT_DIGEST 158 1494 #define EVP_R_NO_DEFAULT_DIGEST 158
1378 #define EVP_R_NO_DIGEST_SET 139 1495 #define EVP_R_NO_DIGEST_SET 139
1379 #define EVP_R_NO_DSA_PARAMETERS 116 1496 #define EVP_R_NO_DSA_PARAMETERS 116
1380 #define EVP_R_NO_KEY_SET 154 1497 #define EVP_R_NO_KEY_SET 154
1381 #define EVP_R_NO_OPERATION_SET 149 1498 #define EVP_R_NO_OPERATION_SET 149
1382 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 1499 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
1383 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 1500 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
1384 #define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 1501 #define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150
1385 #define EVP_R_OPERATON_NOT_INITIALIZED 151 1502 #define EVP_R_OPERATON_NOT_INITIALIZED 151
1503 #define EVP_R_OUTPUT_ALIASES_INPUT 170
1386 #define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 1504 #define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
1387 #define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 1505 #define EVP_R_PRIVATE_KEY_DECODE_ERROR 145
1388 #define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 1506 #define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146
1389 #define EVP_R_PUBLIC_KEY_NOT_RSA 106 1507 #define EVP_R_PUBLIC_KEY_NOT_RSA 106
1508 #define EVP_R_TAG_TOO_LARGE 171
1390 #define EVP_R_TOO_LARGE 164 1509 #define EVP_R_TOO_LARGE 164
1391 #define EVP_R_UNKNOWN_CIPHER 160 1510 #define EVP_R_UNKNOWN_CIPHER 160
1392 #define EVP_R_UNKNOWN_DIGEST 161 1511 #define EVP_R_UNKNOWN_DIGEST 161
1393 #define EVP_R_UNKNOWN_OPTION 169 1512 #define EVP_R_UNKNOWN_OPTION 169
1394 #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 1513 #define EVP_R_UNKNOWN_PBE_ALGORITHM 121
1395 #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 1514 #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
1396 #define EVP_R_UNSUPPORTED_ALGORITHM 156 1515 #define EVP_R_UNSUPPORTED_ALGORITHM 156
1397 #define EVP_R_UNSUPPORTED_CIPHER 107 1516 #define EVP_R_UNSUPPORTED_CIPHER 107
1398 #define EVP_R_UNSUPPORTED_KEYLENGTH 123 1517 #define EVP_R_UNSUPPORTED_KEYLENGTH 123
1399 #define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 1518 #define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
1400 #define EVP_R_UNSUPPORTED_KEY_SIZE 108 1519 #define EVP_R_UNSUPPORTED_KEY_SIZE 108
1401 #define EVP_R_UNSUPPORTED_PRF 125 1520 #define EVP_R_UNSUPPORTED_PRF 125
1402 #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 1521 #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
1403 #define EVP_R_UNSUPPORTED_SALT_TYPE 126 1522 #define EVP_R_UNSUPPORTED_SALT_TYPE 126
1404 #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 1523 #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
1405 #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 1524 #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
1406 1525
1407 #ifdef __cplusplus 1526 #ifdef __cplusplus
1408 } 1527 }
1409 #endif 1528 #endif
1410 #endif 1529 #endif
OLDNEW
« no previous file with comments | « openssl/crypto/evp/e_chacha20poly1305.c ('k') | openssl/crypto/evp/evp_aead.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698