| 
									
										
										
										
											2016-05-18 02:24:46 +08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 20:40:06 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 02:24:46 +08:00
										 |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2015-05-14 22:56:48 +08:00
										 |  |  | #include "internal/cryptlib.h"
 | 
					
						
							| 
									
										
										
										
											2003-03-21 07:28:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef OPENSSL_NO_CAST
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # include <openssl/evp.h>
 | 
					
						
							|  |  |  | # include <openssl/objects.h>
 | 
					
						
							| 
									
										
										
										
											2015-12-19 00:01:28 +08:00
										 |  |  | # include "internal/evp_int.h"
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # include <openssl/cast.h>
 | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-03 22:13:58 +08:00
										 |  |  | static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                          const unsigned char *iv, int enc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     CAST_KEY ks; | 
					
						
							|  |  |  | } EVP_CAST_KEY; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # define data(ctx)       EVP_C_DATA(EVP_CAST_KEY,ctx)
 | 
					
						
							| 
									
										
										
										
											2001-07-31 07:57:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY, | 
					
						
							|  |  |  |                        NID_cast5, 8, CAST_KEY_LENGTH, 8, 64, | 
					
						
							|  |  |  |                        EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL, | 
					
						
							|  |  |  |                        EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) | 
					
						
							| 
									
										
										
										
											2001-07-31 07:57:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-03 22:13:58 +08:00
										 |  |  | static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                          const unsigned char *iv, int enc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     CAST_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 |