cipher-3des1.c (221420) | cipher-3des1.c (255767) |
---|---|
1/* $OpenBSD: cipher-3des1.c,v 1.7 2010/10/01 23:05:32 djm Exp $ */ | 1/* $OpenBSD: cipher-3des1.c,v 1.8 2013/05/17 00:13:13 djm Exp $ */ |
2/* 3 * Copyright (c) 2003 Markus Friedl. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 79 unchanged lines hidden (view full) --- 89 EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc); 90 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc); 91 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc); 92#else 93 if (EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc) == 0 || 94 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc) == 0 || 95 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc) == 0) { 96 memset(c, 0, sizeof(*c)); | 2/* 3 * Copyright (c) 2003 Markus Friedl. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 79 unchanged lines hidden (view full) --- 89 EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc); 90 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc); 91 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc); 92#else 93 if (EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc) == 0 || 94 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc) == 0 || 95 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc) == 0) { 96 memset(c, 0, sizeof(*c)); |
97 xfree(c); | 97 free(c); |
98 EVP_CIPHER_CTX_set_app_data(ctx, NULL); 99 return (0); 100 } 101#endif 102 return (1); 103} 104 105static int --- 24 unchanged lines hidden (view full) --- 130{ 131 struct ssh1_3des_ctx *c; 132 133 if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) { 134 EVP_CIPHER_CTX_cleanup(&c->k1); 135 EVP_CIPHER_CTX_cleanup(&c->k2); 136 EVP_CIPHER_CTX_cleanup(&c->k3); 137 memset(c, 0, sizeof(*c)); | 98 EVP_CIPHER_CTX_set_app_data(ctx, NULL); 99 return (0); 100 } 101#endif 102 return (1); 103} 104 105static int --- 24 unchanged lines hidden (view full) --- 130{ 131 struct ssh1_3des_ctx *c; 132 133 if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) { 134 EVP_CIPHER_CTX_cleanup(&c->k1); 135 EVP_CIPHER_CTX_cleanup(&c->k2); 136 EVP_CIPHER_CTX_cleanup(&c->k3); 137 memset(c, 0, sizeof(*c)); |
138 xfree(c); | 138 free(c); |
139 EVP_CIPHER_CTX_set_app_data(ctx, NULL); 140 } 141 return (1); 142} 143 144void 145ssh1_3des_iv(EVP_CIPHER_CTX *evp, int doset, u_char *iv, int len) 146{ --- 37 unchanged lines hidden --- | 139 EVP_CIPHER_CTX_set_app_data(ctx, NULL); 140 } 141 return (1); 142} 143 144void 145ssh1_3des_iv(EVP_CIPHER_CTX *evp, int doset, u_char *iv, int len) 146{ --- 37 unchanged lines hidden --- |