e_aes_cbc_hmac_sha1.c revision 296341
1/* ==================================================================== 2 * Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * 3. All advertising materials mentioning features or use of this 17 * software must display the following acknowledgment: 18 * "This product includes software developed by the OpenSSL Project 19 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20 * 21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 * endorse or promote products derived from this software without 23 * prior written permission. For written permission, please contact 24 * licensing@OpenSSL.org. 25 * 26 * 5. Products derived from this software may not be called "OpenSSL" 27 * nor may "OpenSSL" appear in their names without prior written 28 * permission of the OpenSSL Project. 29 * 30 * 6. Redistributions of any form whatsoever must retain the following 31 * acknowledgment: 32 * "This product includes software developed by the OpenSSL Project 33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34 * 35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 * OF THE POSSIBILITY OF SUCH DAMAGE. 47 * ==================================================================== 48 */ 49 50#include <openssl/opensslconf.h> 51 52#include <stdio.h> 53#include <string.h> 54 55#if !defined(OPENSSL_NO_AES) && !defined(OPENSSL_NO_SHA1) 56 57# include <openssl/evp.h> 58# include <openssl/objects.h> 59# include <openssl/aes.h> 60# include <openssl/sha.h> 61# include "evp_locl.h" 62 63# ifndef EVP_CIPH_FLAG_AEAD_CIPHER 64# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 65# define EVP_CTRL_AEAD_TLS1_AAD 0x16 66# define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 67# endif 68 69# if !defined(EVP_CIPH_FLAG_DEFAULT_ASN1) 70# define EVP_CIPH_FLAG_DEFAULT_ASN1 0 71# endif 72 73# define TLS1_1_VERSION 0x0302 74 75typedef struct { 76 AES_KEY ks; 77 SHA_CTX head, tail, md; 78 size_t payload_length; /* AAD length in decrypt case */ 79 union { 80 unsigned int tls_ver; 81 unsigned char tls_aad[16]; /* 13 used */ 82 } aux; 83} EVP_AES_HMAC_SHA1; 84 85# define NO_PAYLOAD_LENGTH ((size_t)-1) 86 87# if defined(AES_ASM) && ( \ 88 defined(__x86_64) || defined(__x86_64__) || \ 89 defined(_M_AMD64) || defined(_M_X64) || \ 90 defined(__INTEL__) ) 91 92# if defined(__GNUC__) && __GNUC__>=2 && !defined(PEDANTIC) 93# define BSWAP(x) ({ unsigned int r=(x); asm ("bswapl %0":"=r"(r):"0"(r)); r; }) 94# endif 95 96extern unsigned int OPENSSL_ia32cap_P[2]; 97# define AESNI_CAPABLE (1<<(57-32)) 98 99int aesni_set_encrypt_key(const unsigned char *userKey, int bits, 100 AES_KEY *key); 101int aesni_set_decrypt_key(const unsigned char *userKey, int bits, 102 AES_KEY *key); 103 104void aesni_cbc_encrypt(const unsigned char *in, 105 unsigned char *out, 106 size_t length, 107 const AES_KEY *key, unsigned char *ivec, int enc); 108 109void aesni_cbc_sha1_enc(const void *inp, void *out, size_t blocks, 110 const AES_KEY *key, unsigned char iv[16], 111 SHA_CTX *ctx, const void *in0); 112 113# define data(ctx) ((EVP_AES_HMAC_SHA1 *)(ctx)->cipher_data) 114 115static int aesni_cbc_hmac_sha1_init_key(EVP_CIPHER_CTX *ctx, 116 const unsigned char *inkey, 117 const unsigned char *iv, int enc) 118{ 119 EVP_AES_HMAC_SHA1 *key = data(ctx); 120 int ret; 121 122 if (enc) 123 ret = aesni_set_encrypt_key(inkey, ctx->key_len * 8, &key->ks); 124 else 125 ret = aesni_set_decrypt_key(inkey, ctx->key_len * 8, &key->ks); 126 127 SHA1_Init(&key->head); /* handy when benchmarking */ 128 key->tail = key->head; 129 key->md = key->head; 130 131 key->payload_length = NO_PAYLOAD_LENGTH; 132 133 return ret < 0 ? 0 : 1; 134} 135 136# define STITCHED_CALL 137 138# if !defined(STITCHED_CALL) 139# define aes_off 0 140# endif 141 142void sha1_block_data_order(void *c, const void *p, size_t len); 143 144static void sha1_update(SHA_CTX *c, const void *data, size_t len) 145{ 146 const unsigned char *ptr = data; 147 size_t res; 148 149 if ((res = c->num)) { 150 res = SHA_CBLOCK - res; 151 if (len < res) 152 res = len; 153 SHA1_Update(c, ptr, res); 154 ptr += res; 155 len -= res; 156 } 157 158 res = len % SHA_CBLOCK; 159 len -= res; 160 161 if (len) { 162 sha1_block_data_order(c, ptr, len / SHA_CBLOCK); 163 164 ptr += len; 165 c->Nh += len >> 29; 166 c->Nl += len <<= 3; 167 if (c->Nl < (unsigned int)len) 168 c->Nh++; 169 } 170 171 if (res) 172 SHA1_Update(c, ptr, res); 173} 174 175# ifdef SHA1_Update 176# undef SHA1_Update 177# endif 178# define SHA1_Update sha1_update 179 180static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 181 const unsigned char *in, size_t len) 182{ 183 EVP_AES_HMAC_SHA1 *key = data(ctx); 184 unsigned int l; 185 size_t plen = key->payload_length, iv = 0, /* explicit IV in TLS 1.1 and 186 * later */ 187 sha_off = 0; 188# if defined(STITCHED_CALL) 189 size_t aes_off = 0, blocks; 190 191 sha_off = SHA_CBLOCK - key->md.num; 192# endif 193 194 key->payload_length = NO_PAYLOAD_LENGTH; 195 196 if (len % AES_BLOCK_SIZE) 197 return 0; 198 199 if (ctx->encrypt) { 200 if (plen == NO_PAYLOAD_LENGTH) 201 plen = len; 202 else if (len != 203 ((plen + SHA_DIGEST_LENGTH + 204 AES_BLOCK_SIZE) & -AES_BLOCK_SIZE)) 205 return 0; 206 else if (key->aux.tls_ver >= TLS1_1_VERSION) 207 iv = AES_BLOCK_SIZE; 208 209# if defined(STITCHED_CALL) 210 if (plen > (sha_off + iv) 211 && (blocks = (plen - (sha_off + iv)) / SHA_CBLOCK)) { 212 SHA1_Update(&key->md, in + iv, sha_off); 213 214 aesni_cbc_sha1_enc(in, out, blocks, &key->ks, 215 ctx->iv, &key->md, in + iv + sha_off); 216 blocks *= SHA_CBLOCK; 217 aes_off += blocks; 218 sha_off += blocks; 219 key->md.Nh += blocks >> 29; 220 key->md.Nl += blocks <<= 3; 221 if (key->md.Nl < (unsigned int)blocks) 222 key->md.Nh++; 223 } else { 224 sha_off = 0; 225 } 226# endif 227 sha_off += iv; 228 SHA1_Update(&key->md, in + sha_off, plen - sha_off); 229 230 if (plen != len) { /* "TLS" mode of operation */ 231 if (in != out) 232 memcpy(out + aes_off, in + aes_off, plen - aes_off); 233 234 /* calculate HMAC and append it to payload */ 235 SHA1_Final(out + plen, &key->md); 236 key->md = key->tail; 237 SHA1_Update(&key->md, out + plen, SHA_DIGEST_LENGTH); 238 SHA1_Final(out + plen, &key->md); 239 240 /* pad the payload|hmac */ 241 plen += SHA_DIGEST_LENGTH; 242 for (l = len - plen - 1; plen < len; plen++) 243 out[plen] = l; 244 /* encrypt HMAC|padding at once */ 245 aesni_cbc_encrypt(out + aes_off, out + aes_off, len - aes_off, 246 &key->ks, ctx->iv, 1); 247 } else { 248 aesni_cbc_encrypt(in + aes_off, out + aes_off, len - aes_off, 249 &key->ks, ctx->iv, 1); 250 } 251 } else { 252 union { 253 unsigned int u[SHA_DIGEST_LENGTH / sizeof(unsigned int)]; 254 unsigned char c[32 + SHA_DIGEST_LENGTH]; 255 } mac, *pmac; 256 257 /* arrange cache line alignment */ 258 pmac = (void *)(((size_t)mac.c + 31) & ((size_t)0 - 32)); 259 260 /* decrypt HMAC|padding at once */ 261 aesni_cbc_encrypt(in, out, len, &key->ks, ctx->iv, 0); 262 263 if (plen) { /* "TLS" mode of operation */ 264 size_t inp_len, mask, j, i; 265 unsigned int res, maxpad, pad, bitlen; 266 int ret = 1; 267 union { 268 unsigned int u[SHA_LBLOCK]; 269 unsigned char c[SHA_CBLOCK]; 270 } *data = (void *)key->md.data; 271 272 if ((key->aux.tls_aad[plen - 4] << 8 | key->aux.tls_aad[plen - 3]) 273 >= TLS1_1_VERSION) 274 iv = AES_BLOCK_SIZE; 275 276 if (len < (iv + SHA_DIGEST_LENGTH + 1)) 277 return 0; 278 279 /* omit explicit iv */ 280 out += iv; 281 len -= iv; 282 283 /* figure out payload length */ 284 pad = out[len - 1]; 285 maxpad = len - (SHA_DIGEST_LENGTH + 1); 286 maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); 287 maxpad &= 255; 288 289 inp_len = len - (SHA_DIGEST_LENGTH + pad + 1); 290 mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); 291 inp_len &= mask; 292 ret &= (int)mask; 293 294 key->aux.tls_aad[plen - 2] = inp_len >> 8; 295 key->aux.tls_aad[plen - 1] = inp_len; 296 297 /* calculate HMAC */ 298 key->md = key->head; 299 SHA1_Update(&key->md, key->aux.tls_aad, plen); 300 301# if 1 302 len -= SHA_DIGEST_LENGTH; /* amend mac */ 303 if (len >= (256 + SHA_CBLOCK)) { 304 j = (len - (256 + SHA_CBLOCK)) & (0 - SHA_CBLOCK); 305 j += SHA_CBLOCK - key->md.num; 306 SHA1_Update(&key->md, out, j); 307 out += j; 308 len -= j; 309 inp_len -= j; 310 } 311 312 /* but pretend as if we hashed padded payload */ 313 bitlen = key->md.Nl + (inp_len << 3); /* at most 18 bits */ 314# ifdef BSWAP 315 bitlen = BSWAP(bitlen); 316# else 317 mac.c[0] = 0; 318 mac.c[1] = (unsigned char)(bitlen >> 16); 319 mac.c[2] = (unsigned char)(bitlen >> 8); 320 mac.c[3] = (unsigned char)bitlen; 321 bitlen = mac.u[0]; 322# endif 323 324 pmac->u[0] = 0; 325 pmac->u[1] = 0; 326 pmac->u[2] = 0; 327 pmac->u[3] = 0; 328 pmac->u[4] = 0; 329 330 for (res = key->md.num, j = 0; j < len; j++) { 331 size_t c = out[j]; 332 mask = (j - inp_len) >> (sizeof(j) * 8 - 8); 333 c &= mask; 334 c |= 0x80 & ~mask & ~((inp_len - j) >> (sizeof(j) * 8 - 8)); 335 data->c[res++] = (unsigned char)c; 336 337 if (res != SHA_CBLOCK) 338 continue; 339 340 /* j is not incremented yet */ 341 mask = 0 - ((inp_len + 7 - j) >> (sizeof(j) * 8 - 1)); 342 data->u[SHA_LBLOCK - 1] |= bitlen & mask; 343 sha1_block_data_order(&key->md, data, 1); 344 mask &= 0 - ((j - inp_len - 72) >> (sizeof(j) * 8 - 1)); 345 pmac->u[0] |= key->md.h0 & mask; 346 pmac->u[1] |= key->md.h1 & mask; 347 pmac->u[2] |= key->md.h2 & mask; 348 pmac->u[3] |= key->md.h3 & mask; 349 pmac->u[4] |= key->md.h4 & mask; 350 res = 0; 351 } 352 353 for (i = res; i < SHA_CBLOCK; i++, j++) 354 data->c[i] = 0; 355 356 if (res > SHA_CBLOCK - 8) { 357 mask = 0 - ((inp_len + 8 - j) >> (sizeof(j) * 8 - 1)); 358 data->u[SHA_LBLOCK - 1] |= bitlen & mask; 359 sha1_block_data_order(&key->md, data, 1); 360 mask &= 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1)); 361 pmac->u[0] |= key->md.h0 & mask; 362 pmac->u[1] |= key->md.h1 & mask; 363 pmac->u[2] |= key->md.h2 & mask; 364 pmac->u[3] |= key->md.h3 & mask; 365 pmac->u[4] |= key->md.h4 & mask; 366 367 memset(data, 0, SHA_CBLOCK); 368 j += 64; 369 } 370 data->u[SHA_LBLOCK - 1] = bitlen; 371 sha1_block_data_order(&key->md, data, 1); 372 mask = 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1)); 373 pmac->u[0] |= key->md.h0 & mask; 374 pmac->u[1] |= key->md.h1 & mask; 375 pmac->u[2] |= key->md.h2 & mask; 376 pmac->u[3] |= key->md.h3 & mask; 377 pmac->u[4] |= key->md.h4 & mask; 378 379# ifdef BSWAP 380 pmac->u[0] = BSWAP(pmac->u[0]); 381 pmac->u[1] = BSWAP(pmac->u[1]); 382 pmac->u[2] = BSWAP(pmac->u[2]); 383 pmac->u[3] = BSWAP(pmac->u[3]); 384 pmac->u[4] = BSWAP(pmac->u[4]); 385# else 386 for (i = 0; i < 5; i++) { 387 res = pmac->u[i]; 388 pmac->c[4 * i + 0] = (unsigned char)(res >> 24); 389 pmac->c[4 * i + 1] = (unsigned char)(res >> 16); 390 pmac->c[4 * i + 2] = (unsigned char)(res >> 8); 391 pmac->c[4 * i + 3] = (unsigned char)res; 392 } 393# endif 394 len += SHA_DIGEST_LENGTH; 395# else 396 SHA1_Update(&key->md, out, inp_len); 397 res = key->md.num; 398 SHA1_Final(pmac->c, &key->md); 399 400 { 401 unsigned int inp_blocks, pad_blocks; 402 403 /* but pretend as if we hashed padded payload */ 404 inp_blocks = 405 1 + ((SHA_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1)); 406 res += (unsigned int)(len - inp_len); 407 pad_blocks = res / SHA_CBLOCK; 408 res %= SHA_CBLOCK; 409 pad_blocks += 410 1 + ((SHA_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1)); 411 for (; inp_blocks < pad_blocks; inp_blocks++) 412 sha1_block_data_order(&key->md, data, 1); 413 } 414# endif 415 key->md = key->tail; 416 SHA1_Update(&key->md, pmac->c, SHA_DIGEST_LENGTH); 417 SHA1_Final(pmac->c, &key->md); 418 419 /* verify HMAC */ 420 out += inp_len; 421 len -= inp_len; 422# if 1 423 { 424 unsigned char *p = out + len - 1 - maxpad - SHA_DIGEST_LENGTH; 425 size_t off = out - p; 426 unsigned int c, cmask; 427 428 maxpad += SHA_DIGEST_LENGTH; 429 for (res = 0, i = 0, j = 0; j < maxpad; j++) { 430 c = p[j]; 431 cmask = 432 ((int)(j - off - SHA_DIGEST_LENGTH)) >> (sizeof(int) * 433 8 - 1); 434 res |= (c ^ pad) & ~cmask; /* ... and padding */ 435 cmask &= ((int)(off - 1 - j)) >> (sizeof(int) * 8 - 1); 436 res |= (c ^ pmac->c[i]) & cmask; 437 i += 1 & cmask; 438 } 439 maxpad -= SHA_DIGEST_LENGTH; 440 441 res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1)); 442 ret &= (int)~res; 443 } 444# else 445 for (res = 0, i = 0; i < SHA_DIGEST_LENGTH; i++) 446 res |= out[i] ^ pmac->c[i]; 447 res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1)); 448 ret &= (int)~res; 449 450 /* verify padding */ 451 pad = (pad & ~res) | (maxpad & res); 452 out = out + len - 1 - pad; 453 for (res = 0, i = 0; i < pad; i++) 454 res |= out[i] ^ pad; 455 456 res = (0 - res) >> (sizeof(res) * 8 - 1); 457 ret &= (int)~res; 458# endif 459 return ret; 460 } else { 461 SHA1_Update(&key->md, out, len); 462 } 463 } 464 465 return 1; 466} 467 468static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, 469 void *ptr) 470{ 471 EVP_AES_HMAC_SHA1 *key = data(ctx); 472 473 switch (type) { 474 case EVP_CTRL_AEAD_SET_MAC_KEY: 475 { 476 unsigned int i; 477 unsigned char hmac_key[64]; 478 479 memset(hmac_key, 0, sizeof(hmac_key)); 480 481 if (arg > (int)sizeof(hmac_key)) { 482 SHA1_Init(&key->head); 483 SHA1_Update(&key->head, ptr, arg); 484 SHA1_Final(hmac_key, &key->head); 485 } else { 486 memcpy(hmac_key, ptr, arg); 487 } 488 489 for (i = 0; i < sizeof(hmac_key); i++) 490 hmac_key[i] ^= 0x36; /* ipad */ 491 SHA1_Init(&key->head); 492 SHA1_Update(&key->head, hmac_key, sizeof(hmac_key)); 493 494 for (i = 0; i < sizeof(hmac_key); i++) 495 hmac_key[i] ^= 0x36 ^ 0x5c; /* opad */ 496 SHA1_Init(&key->tail); 497 SHA1_Update(&key->tail, hmac_key, sizeof(hmac_key)); 498 499 OPENSSL_cleanse(hmac_key, sizeof(hmac_key)); 500 501 return 1; 502 } 503 case EVP_CTRL_AEAD_TLS1_AAD: 504 { 505 unsigned char *p = ptr; 506 unsigned int len; 507 508 if (arg != EVP_AEAD_TLS1_AAD_LEN) 509 return -1; 510 511 len = p[arg - 2] << 8 | p[arg - 1]; 512 513 if (ctx->encrypt) { 514 key->payload_length = len; 515 if ((key->aux.tls_ver = 516 p[arg - 4] << 8 | p[arg - 3]) >= TLS1_1_VERSION) { 517 len -= AES_BLOCK_SIZE; 518 p[arg - 2] = len >> 8; 519 p[arg - 1] = len; 520 } 521 key->md = key->head; 522 SHA1_Update(&key->md, p, arg); 523 524 return (int)(((len + SHA_DIGEST_LENGTH + 525 AES_BLOCK_SIZE) & -AES_BLOCK_SIZE) 526 - len); 527 } else { 528 memcpy(key->aux.tls_aad, ptr, arg); 529 key->payload_length = arg; 530 531 return SHA_DIGEST_LENGTH; 532 } 533 } 534 default: 535 return -1; 536 } 537} 538 539static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = { 540# ifdef NID_aes_128_cbc_hmac_sha1 541 NID_aes_128_cbc_hmac_sha1, 542# else 543 NID_undef, 544# endif 545 16, 16, 16, 546 EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 | 547 EVP_CIPH_FLAG_AEAD_CIPHER, 548 aesni_cbc_hmac_sha1_init_key, 549 aesni_cbc_hmac_sha1_cipher, 550 NULL, 551 sizeof(EVP_AES_HMAC_SHA1), 552 EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_set_asn1_iv, 553 EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_get_asn1_iv, 554 aesni_cbc_hmac_sha1_ctrl, 555 NULL 556}; 557 558static EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = { 559# ifdef NID_aes_256_cbc_hmac_sha1 560 NID_aes_256_cbc_hmac_sha1, 561# else 562 NID_undef, 563# endif 564 16, 32, 16, 565 EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_DEFAULT_ASN1 | 566 EVP_CIPH_FLAG_AEAD_CIPHER, 567 aesni_cbc_hmac_sha1_init_key, 568 aesni_cbc_hmac_sha1_cipher, 569 NULL, 570 sizeof(EVP_AES_HMAC_SHA1), 571 EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_set_asn1_iv, 572 EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_get_asn1_iv, 573 aesni_cbc_hmac_sha1_ctrl, 574 NULL 575}; 576 577const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void) 578{ 579 return (OPENSSL_ia32cap_P[1] & AESNI_CAPABLE ? 580 &aesni_128_cbc_hmac_sha1_cipher : NULL); 581} 582 583const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void) 584{ 585 return (OPENSSL_ia32cap_P[1] & AESNI_CAPABLE ? 586 &aesni_256_cbc_hmac_sha1_cipher : NULL); 587} 588# else 589const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void) 590{ 591 return NULL; 592} 593 594const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void) 595{ 596 return NULL; 597} 598# endif 599#endif 600