2 * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * Support for PVK format keys and related structures (such a PUBLICKEYBLOB
12 * and PRIVATEKEYBLOB).
15 #include "internal/cryptlib.h"
16 #include <openssl/pem.h>
17 #include <openssl/rand.h>
18 #include <openssl/bn.h>
19 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA)
20 # include <openssl/dsa.h>
21 # include <openssl/rsa.h>
24 * Utility function: read a DWORD (4 byte unsigned integer) in little endian
28 static unsigned int read_ledword(const unsigned char **in)
30 const unsigned char *p = *in;
41 * Read a BIGNUM in little endian format. The docs say that this should take
45 static int read_lebn(const unsigned char **in, unsigned int nbyte, BIGNUM **r)
47 *r = BN_lebin2bn(*in, nbyte, NULL);
54 /* Convert private key blob to EVP_PKEY: RSA and DSA keys supported */
56 # define MS_PUBLICKEYBLOB 0x6
57 # define MS_PRIVATEKEYBLOB 0x7
58 # define MS_RSA1MAGIC 0x31415352L
59 # define MS_RSA2MAGIC 0x32415352L
60 # define MS_DSS1MAGIC 0x31535344L
61 # define MS_DSS2MAGIC 0x32535344L
63 # define MS_KEYALG_RSA_KEYX 0xa400
64 # define MS_KEYALG_DSS_SIGN 0x2200
66 # define MS_KEYTYPE_KEYX 0x1
67 # define MS_KEYTYPE_SIGN 0x2
69 /* Maximum length of a blob after header */
70 # define BLOB_MAX_LENGTH 102400
72 /* The PVK file magic number: seems to spell out "bobsfile", who is Bob? */
73 # define MS_PVKMAGIC 0xb0b5f11eL
74 /* Salt length for PVK files */
75 # define PVK_SALTLEN 0x10
76 /* Maximum length in PVK header */
77 # define PVK_MAX_KEYLEN 102400
78 /* Maximum salt length */
79 # define PVK_MAX_SALTLEN 10240
81 static EVP_PKEY *b2i_rsa(const unsigned char **in,
82 unsigned int bitlen, int ispub);
83 static EVP_PKEY *b2i_dss(const unsigned char **in,
84 unsigned int bitlen, int ispub);
86 static int do_blob_header(const unsigned char **in, unsigned int length,
87 unsigned int *pmagic, unsigned int *pbitlen,
88 int *pisdss, int *pispub)
90 const unsigned char *p = *in;
94 if (*p == MS_PUBLICKEYBLOB) {
96 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PRIVATE_KEY_BLOB);
100 } else if (*p == MS_PRIVATEKEYBLOB) {
102 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PUBLIC_KEY_BLOB);
111 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_BAD_VERSION_NUMBER);
114 /* Ignore reserved, aiKeyAlg */
116 *pmagic = read_ledword(&p);
117 *pbitlen = read_ledword(&p);
126 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PRIVATE_KEY_BLOB);
136 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PUBLIC_KEY_BLOB);
142 PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_BAD_MAGIC_NUMBER);
149 static unsigned int blob_length(unsigned bitlen, int isdss, int ispub)
151 unsigned int nbyte, hnbyte;
152 nbyte = (bitlen + 7) >> 3;
153 hnbyte = (bitlen + 15) >> 4;
157 * Expected length: 20 for q + 3 components bitlen each + 24 for seed
161 return 44 + 3 * nbyte;
163 * Expected length: 20 for q, priv, 2 bitlen components + 24 for seed
167 return 64 + 2 * nbyte;
169 /* Expected length: 4 for 'e' + 'n' */
174 * Expected length: 4 for 'e' and 7 other components. 2
175 * components are bitlen size, 5 are bitlen/2
177 return 4 + 2 * nbyte + 5 * hnbyte;
182 static EVP_PKEY *do_b2i(const unsigned char **in, unsigned int length,
185 const unsigned char *p = *in;
186 unsigned int bitlen, magic;
188 if (do_blob_header(&p, length, &magic, &bitlen, &isdss, &ispub) <= 0) {
189 PEMerr(PEM_F_DO_B2I, PEM_R_KEYBLOB_HEADER_PARSE_ERROR);
193 if (length < blob_length(bitlen, isdss, ispub)) {
194 PEMerr(PEM_F_DO_B2I, PEM_R_KEYBLOB_TOO_SHORT);
198 return b2i_dss(&p, bitlen, ispub);
200 return b2i_rsa(&p, bitlen, ispub);
203 static EVP_PKEY *do_b2i_bio(BIO *in, int ispub)
205 const unsigned char *p;
206 unsigned char hdr_buf[16], *buf = NULL;
207 unsigned int bitlen, magic, length;
209 EVP_PKEY *ret = NULL;
210 if (BIO_read(in, hdr_buf, 16) != 16) {
211 PEMerr(PEM_F_DO_B2I_BIO, PEM_R_KEYBLOB_TOO_SHORT);
215 if (do_blob_header(&p, 16, &magic, &bitlen, &isdss, &ispub) <= 0)
218 length = blob_length(bitlen, isdss, ispub);
219 if (length > BLOB_MAX_LENGTH) {
220 PEMerr(PEM_F_DO_B2I_BIO, PEM_R_HEADER_TOO_LONG);
223 buf = OPENSSL_malloc(length);
225 PEMerr(PEM_F_DO_B2I_BIO, ERR_R_MALLOC_FAILURE);
229 if (BIO_read(in, buf, length) != (int)length) {
230 PEMerr(PEM_F_DO_B2I_BIO, PEM_R_KEYBLOB_TOO_SHORT);
235 ret = b2i_dss(&p, bitlen, ispub);
237 ret = b2i_rsa(&p, bitlen, ispub);
244 static EVP_PKEY *b2i_dss(const unsigned char **in,
245 unsigned int bitlen, int ispub)
247 const unsigned char *p = *in;
248 EVP_PKEY *ret = NULL;
252 BIGNUM *pbn = NULL, *qbn = NULL, *gbn = NULL, *priv_key = NULL;
253 BIGNUM *pub_key = NULL;
255 nbyte = (bitlen + 7) >> 3;
258 ret = EVP_PKEY_new();
259 if (dsa == NULL || ret == NULL)
261 if (!read_lebn(&p, nbyte, &pbn))
264 if (!read_lebn(&p, 20, &qbn))
267 if (!read_lebn(&p, nbyte, &gbn))
271 if (!read_lebn(&p, nbyte, &pub_key))
274 if (!read_lebn(&p, 20, &priv_key))
277 /* Set constant time flag before public key calculation */
278 BN_set_flags(priv_key, BN_FLG_CONSTTIME);
280 /* Calculate public key */
284 if ((ctx = BN_CTX_new()) == NULL)
287 if (!BN_mod_exp(pub_key, gbn, priv_key, pbn, ctx))
293 if (!DSA_set0_pqg(dsa, pbn, qbn, gbn))
295 pbn = qbn = gbn = NULL;
296 if (!DSA_set0_key(dsa, pub_key, priv_key))
298 pub_key = priv_key = NULL;
300 if (!EVP_PKEY_set1_DSA(ret, dsa))
307 PEMerr(PEM_F_B2I_DSS, ERR_R_MALLOC_FAILURE);
319 static EVP_PKEY *b2i_rsa(const unsigned char **in,
320 unsigned int bitlen, int ispub)
322 const unsigned char *pin = *in;
323 EVP_PKEY *ret = NULL;
324 BIGNUM *e = NULL, *n = NULL, *d = NULL;
325 BIGNUM *p = NULL, *q = NULL, *dmp1 = NULL, *dmq1 = NULL, *iqmp = NULL;
327 unsigned int nbyte, hnbyte;
328 nbyte = (bitlen + 7) >> 3;
329 hnbyte = (bitlen + 15) >> 4;
331 ret = EVP_PKEY_new();
332 if (rsa == NULL || ret == NULL)
337 if (!BN_set_word(e, read_ledword(&pin)))
339 if (!read_lebn(&pin, nbyte, &n))
342 if (!read_lebn(&pin, hnbyte, &p))
344 if (!read_lebn(&pin, hnbyte, &q))
346 if (!read_lebn(&pin, hnbyte, &dmp1))
348 if (!read_lebn(&pin, hnbyte, &dmq1))
350 if (!read_lebn(&pin, hnbyte, &iqmp))
352 if (!read_lebn(&pin, nbyte, &d))
354 if (!RSA_set0_factors(rsa, p, q))
357 if (!RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp))
359 dmp1 = dmq1 = iqmp = NULL;
361 if (!RSA_set0_key(rsa, n, e, d))
365 if (!EVP_PKEY_set1_RSA(ret, rsa))
371 PEMerr(PEM_F_B2I_RSA, ERR_R_MALLOC_FAILURE);
385 EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length)
387 return do_b2i(in, length, 0);
390 EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length)
392 return do_b2i(in, length, 1);
395 EVP_PKEY *b2i_PrivateKey_bio(BIO *in)
397 return do_b2i_bio(in, 0);
400 EVP_PKEY *b2i_PublicKey_bio(BIO *in)
402 return do_b2i_bio(in, 1);
405 static void write_ledword(unsigned char **out, unsigned int dw)
407 unsigned char *p = *out;
409 *p++ = (dw >> 8) & 0xff;
410 *p++ = (dw >> 16) & 0xff;
411 *p++ = (dw >> 24) & 0xff;
415 static void write_lebn(unsigned char **out, const BIGNUM *bn, int len)
417 BN_bn2lebinpad(bn, *out, len);
421 static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *magic);
422 static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *magic);
424 static void write_rsa(unsigned char **out, RSA *rsa, int ispub);
425 static void write_dsa(unsigned char **out, DSA *dsa, int ispub);
427 static int do_i2b(unsigned char **out, EVP_PKEY *pk, int ispub)
430 unsigned int bitlen, magic = 0, keyalg;
431 int outlen, noinc = 0;
432 int pktype = EVP_PKEY_id(pk);
433 if (pktype == EVP_PKEY_DSA) {
434 bitlen = check_bitlen_dsa(EVP_PKEY_get0_DSA(pk), ispub, &magic);
435 keyalg = MS_KEYALG_DSS_SIGN;
436 } else if (pktype == EVP_PKEY_RSA) {
437 bitlen = check_bitlen_rsa(EVP_PKEY_get0_RSA(pk), ispub, &magic);
438 keyalg = MS_KEYALG_RSA_KEYX;
443 outlen = 16 + blob_length(bitlen,
444 keyalg == MS_KEYALG_DSS_SIGN ? 1 : 0, ispub);
450 if ((p = OPENSSL_malloc(outlen)) == NULL) {
451 PEMerr(PEM_F_DO_I2B, ERR_R_MALLOC_FAILURE);
458 *p++ = MS_PUBLICKEYBLOB;
460 *p++ = MS_PRIVATEKEYBLOB;
464 write_ledword(&p, keyalg);
465 write_ledword(&p, magic);
466 write_ledword(&p, bitlen);
467 if (keyalg == MS_KEYALG_DSS_SIGN)
468 write_dsa(&p, EVP_PKEY_get0_DSA(pk), ispub);
470 write_rsa(&p, EVP_PKEY_get0_RSA(pk), ispub);
476 static int do_i2b_bio(BIO *out, EVP_PKEY *pk, int ispub)
478 unsigned char *tmp = NULL;
480 outlen = do_i2b(&tmp, pk, ispub);
483 wrlen = BIO_write(out, tmp, outlen);
490 static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *pmagic)
493 const BIGNUM *p = NULL, *q = NULL, *g = NULL;
494 const BIGNUM *pub_key = NULL, *priv_key = NULL;
496 DSA_get0_pqg(dsa, &p, &q, &g);
497 DSA_get0_key(dsa, &pub_key, &priv_key);
498 bitlen = BN_num_bits(p);
499 if ((bitlen & 7) || (BN_num_bits(q) != 160)
500 || (BN_num_bits(g) > bitlen))
503 if (BN_num_bits(pub_key) > bitlen)
505 *pmagic = MS_DSS1MAGIC;
507 if (BN_num_bits(priv_key) > 160)
509 *pmagic = MS_DSS2MAGIC;
514 PEMerr(PEM_F_CHECK_BITLEN_DSA, PEM_R_UNSUPPORTED_KEY_COMPONENTS);
518 static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic)
520 int nbyte, hnbyte, bitlen;
523 RSA_get0_key(rsa, NULL, &e, NULL);
524 if (BN_num_bits(e) > 32)
526 bitlen = RSA_bits(rsa);
527 nbyte = RSA_size(rsa);
528 hnbyte = (bitlen + 15) >> 4;
530 *pmagic = MS_RSA1MAGIC;
533 const BIGNUM *d, *p, *q, *iqmp, *dmp1, *dmq1;
535 *pmagic = MS_RSA2MAGIC;
538 * For private key each component must fit within nbyte or hnbyte.
540 RSA_get0_key(rsa, NULL, NULL, &d);
541 if (BN_num_bytes(d) > nbyte)
543 RSA_get0_factors(rsa, &p, &q);
544 RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
545 if ((BN_num_bytes(iqmp) > hnbyte)
546 || (BN_num_bytes(p) > hnbyte)
547 || (BN_num_bytes(q) > hnbyte)
548 || (BN_num_bytes(dmp1) > hnbyte)
549 || (BN_num_bytes(dmq1) > hnbyte))
554 PEMerr(PEM_F_CHECK_BITLEN_RSA, PEM_R_UNSUPPORTED_KEY_COMPONENTS);
558 static void write_rsa(unsigned char **out, RSA *rsa, int ispub)
561 const BIGNUM *n, *d, *e, *p, *q, *iqmp, *dmp1, *dmq1;
563 nbyte = RSA_size(rsa);
564 hnbyte = (RSA_bits(rsa) + 15) >> 4;
565 RSA_get0_key(rsa, &n, &e, &d);
566 write_lebn(out, e, 4);
567 write_lebn(out, n, nbyte);
570 RSA_get0_factors(rsa, &p, &q);
571 RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
572 write_lebn(out, p, hnbyte);
573 write_lebn(out, q, hnbyte);
574 write_lebn(out, dmp1, hnbyte);
575 write_lebn(out, dmq1, hnbyte);
576 write_lebn(out, iqmp, hnbyte);
577 write_lebn(out, d, nbyte);
580 static void write_dsa(unsigned char **out, DSA *dsa, int ispub)
583 const BIGNUM *p = NULL, *q = NULL, *g = NULL;
584 const BIGNUM *pub_key = NULL, *priv_key = NULL;
586 DSA_get0_pqg(dsa, &p, &q, &g);
587 DSA_get0_key(dsa, &pub_key, &priv_key);
588 nbyte = BN_num_bytes(p);
589 write_lebn(out, p, nbyte);
590 write_lebn(out, q, 20);
591 write_lebn(out, g, nbyte);
593 write_lebn(out, pub_key, nbyte);
595 write_lebn(out, priv_key, 20);
596 /* Set "invalid" for seed structure values */
597 memset(*out, 0xff, 24);
602 int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk)
604 return do_i2b_bio(out, pk, 0);
607 int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk)
609 return do_i2b_bio(out, pk, 1);
612 # ifndef OPENSSL_NO_RC4
614 static int do_PVK_header(const unsigned char **in, unsigned int length,
616 unsigned int *psaltlen, unsigned int *pkeylen)
618 const unsigned char *p = *in;
619 unsigned int pvk_magic, is_encrypted;
622 PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT);
627 PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT);
630 pvk_magic = read_ledword(&p);
631 if (pvk_magic != MS_PVKMAGIC) {
632 PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER);
641 is_encrypted = read_ledword(&p);
642 *psaltlen = read_ledword(&p);
643 *pkeylen = read_ledword(&p);
645 if (*pkeylen > PVK_MAX_KEYLEN || *psaltlen > PVK_MAX_SALTLEN)
648 if (is_encrypted && !*psaltlen) {
649 PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER);
657 static int derive_pvk_key(unsigned char *key,
658 const unsigned char *salt, unsigned int saltlen,
659 const unsigned char *pass, int passlen)
661 EVP_MD_CTX *mctx = EVP_MD_CTX_new();
664 || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
665 || !EVP_DigestUpdate(mctx, salt, saltlen)
666 || !EVP_DigestUpdate(mctx, pass, passlen)
667 || !EVP_DigestFinal_ex(mctx, key, NULL))
670 EVP_MD_CTX_free(mctx);
674 static EVP_PKEY *do_PVK_body(const unsigned char **in,
675 unsigned int saltlen, unsigned int keylen,
676 pem_password_cb *cb, void *u)
678 EVP_PKEY *ret = NULL;
679 const unsigned char *p = *in;
681 unsigned char *enctmp = NULL, *q;
682 unsigned char keybuf[20];
684 EVP_CIPHER_CTX *cctx = EVP_CIPHER_CTX_new();
686 char psbuf[PEM_BUFSIZE];
687 int enctmplen, inlen;
689 inlen = cb(psbuf, PEM_BUFSIZE, 0, u);
691 inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u);
693 PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_PASSWORD_READ);
696 enctmp = OPENSSL_malloc(keylen + 8);
697 if (enctmp == NULL) {
698 PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE);
701 if (!derive_pvk_key(keybuf, p, saltlen,
702 (unsigned char *)psbuf, inlen))
705 /* Copy BLOBHEADER across, decrypt rest */
706 memcpy(enctmp, p, 8);
709 PEMerr(PEM_F_DO_PVK_BODY, PEM_R_PVK_TOO_SHORT);
714 if (!EVP_DecryptInit_ex(cctx, EVP_rc4(), NULL, keybuf, NULL))
716 if (!EVP_DecryptUpdate(cctx, q, &enctmplen, p, inlen))
718 if (!EVP_DecryptFinal_ex(cctx, q + enctmplen, &enctmplen))
720 magic = read_ledword((const unsigned char **)&q);
721 if (magic != MS_RSA2MAGIC && magic != MS_DSS2MAGIC) {
723 memset(keybuf + 5, 0, 11);
724 if (!EVP_DecryptInit_ex(cctx, EVP_rc4(), NULL, keybuf, NULL))
726 if (!EVP_DecryptUpdate(cctx, q, &enctmplen, p, inlen))
728 if (!EVP_DecryptFinal_ex(cctx, q + enctmplen, &enctmplen))
730 magic = read_ledword((const unsigned char **)&q);
731 if (magic != MS_RSA2MAGIC && magic != MS_DSS2MAGIC) {
732 PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_DECRYPT);
739 ret = b2i_PrivateKey(&p, keylen);
741 EVP_CIPHER_CTX_free(cctx);
742 if (enctmp != NULL) {
743 OPENSSL_cleanse(keybuf, sizeof(keybuf));
744 OPENSSL_free(enctmp);
749 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u)
751 unsigned char pvk_hdr[24], *buf = NULL;
752 const unsigned char *p;
754 EVP_PKEY *ret = NULL;
755 unsigned int saltlen, keylen;
756 if (BIO_read(in, pvk_hdr, 24) != 24) {
757 PEMerr(PEM_F_B2I_PVK_BIO, PEM_R_PVK_DATA_TOO_SHORT);
762 if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen))
764 buflen = (int)keylen + saltlen;
765 buf = OPENSSL_malloc(buflen);
767 PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE);
771 if (BIO_read(in, buf, buflen) != buflen) {
772 PEMerr(PEM_F_B2I_PVK_BIO, PEM_R_PVK_DATA_TOO_SHORT);
775 ret = do_PVK_body(&p, saltlen, keylen, cb, u);
778 OPENSSL_clear_free(buf, buflen);
782 static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel,
783 pem_password_cb *cb, void *u)
785 int outlen = 24, pklen;
786 unsigned char *p = NULL, *start = NULL, *salt = NULL;
787 EVP_CIPHER_CTX *cctx = NULL;
789 outlen += PVK_SALTLEN;
790 pklen = do_i2b(NULL, pk, 0);
799 start = p = OPENSSL_malloc(outlen);
801 PEMerr(PEM_F_I2B_PVK, ERR_R_MALLOC_FAILURE);
806 cctx = EVP_CIPHER_CTX_new();
810 write_ledword(&p, MS_PVKMAGIC);
811 write_ledword(&p, 0);
812 if (EVP_PKEY_id(pk) == EVP_PKEY_DSA)
813 write_ledword(&p, MS_KEYTYPE_SIGN);
815 write_ledword(&p, MS_KEYTYPE_KEYX);
816 write_ledword(&p, enclevel ? 1 : 0);
817 write_ledword(&p, enclevel ? PVK_SALTLEN : 0);
818 write_ledword(&p, pklen);
820 if (RAND_bytes(p, PVK_SALTLEN) <= 0)
827 char psbuf[PEM_BUFSIZE];
828 unsigned char keybuf[20];
829 int enctmplen, inlen;
831 inlen = cb(psbuf, PEM_BUFSIZE, 1, u);
833 inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 1, u);
835 PEMerr(PEM_F_I2B_PVK, PEM_R_BAD_PASSWORD_READ);
838 if (!derive_pvk_key(keybuf, salt, PVK_SALTLEN,
839 (unsigned char *)psbuf, inlen))
842 memset(keybuf + 5, 0, 11);
843 p = salt + PVK_SALTLEN + 8;
844 if (!EVP_EncryptInit_ex(cctx, EVP_rc4(), NULL, keybuf, NULL))
846 OPENSSL_cleanse(keybuf, 20);
847 if (!EVP_DecryptUpdate(cctx, p, &enctmplen, p, pklen - 8))
849 if (!EVP_DecryptFinal_ex(cctx, p + enctmplen, &enctmplen))
853 EVP_CIPHER_CTX_free(cctx);
861 EVP_CIPHER_CTX_free(cctx);
867 int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
868 pem_password_cb *cb, void *u)
870 unsigned char *tmp = NULL;
872 outlen = i2b_PVK(&tmp, pk, enclevel, cb, u);
875 wrlen = BIO_write(out, tmp, outlen);
877 if (wrlen == outlen) {
878 PEMerr(PEM_F_I2B_PVK_BIO, PEM_R_BIO_WRITE_FAILURE);