Lines Matching refs:cipher

1 /* $OpenBSD: cipher.c,v 1.102 2016/08/03 05:41:57 djm Exp $ */
46 #include "cipher.h"
66 const struct sshcipher *cipher;
198 * Default is cipher block size, except for chacha20+poly1305 that
226 return cc->cipher->number;
286 * Parses the name of the cipher. Returns the number of the corresponding
287 * cipher, or -1 on error.
312 if (cc == NULL || cc->cipher == NULL)
314 if (cc->cipher->number == SSH_CIPHER_DES)
321 cipher_init(struct sshcipher_ctx **ccp, const struct sshcipher *cipher,
337 if (cipher->number == SSH_CIPHER_DES) {
342 cc->plaintext = (cipher->number == SSH_CIPHER_NONE);
345 if (keylen < cipher->key_len ||
346 (iv != NULL && ivlen < cipher_ivlen(cipher))) {
351 cc->cipher = cipher;
352 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
357 if ((cc->cipher->flags & CFLAG_AESCTR) != 0) {
363 if ((cc->cipher->flags & CFLAG_NONE) != 0) {
370 type = (*cipher->evptype)();
380 if (cipher_authlen(cipher) &&
398 if (cipher->discard_len > 0) {
399 if ((junk = malloc(cipher->discard_len)) == NULL ||
400 (discard = malloc(cipher->discard_len)) == NULL) {
405 ret = EVP_Cipher(cc->evp, discard, junk, cipher->discard_len);
406 explicit_bzero(discard, cipher->discard_len);
447 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
452 if ((cc->cipher->flags & CFLAG_AESCTR) != 0) {
459 if ((cc->cipher->flags & CFLAG_NONE) != 0) {
468 if (authlen != cipher_authlen(cc->cipher))
486 if (len % cc->cipher->block_size)
510 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
524 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
526 else if ((cc->cipher->flags & CFLAG_AESCTR) != 0)
539 * Selects the cipher, and keys if by computing the MD5 checksum of the
544 const struct sshcipher *cipher, const char *passphrase, int do_encrypt)
554 r = cipher_init(ccp, cipher, digest, 16, NULL, 0, do_encrypt);
568 const struct sshcipher *c = cc->cipher;
573 else if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
575 else if ((cc->cipher->flags & CFLAG_AESCTR) != 0)
587 const struct sshcipher *c = cc->cipher;
592 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
597 if ((cc->cipher->flags & CFLAG_AESCTR) != 0) {
603 if ((cc->cipher->flags & CFLAG_NONE) != 0)
644 const struct sshcipher *c = cc->cipher;
649 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
651 if ((cc->cipher->flags & CFLAG_NONE) != 0)
689 #define EVP_X_STATE_LEN(evp) (evp)->cipher->ctx_size
696 const struct sshcipher *c = cc->cipher;
715 const struct sshcipher *c = cc->cipher;