Home | History | Annotate | Line # | Download | only in digests
      1      1.1  christos /*
      2      1.1  christos  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
      3      1.1  christos  *
      4      1.1  christos  * Licensed under the Apache License 2.0 (the "License").  You may not use
      5      1.1  christos  * this file except in compliance with the License.  You can obtain a copy
      6      1.1  christos  * in the file LICENSE in the source distribution or at
      7      1.1  christos  * https://www.openssl.org/source/license.html
      8      1.1  christos  */
      9      1.1  christos 
     10      1.1  christos #include <openssl/err.h>
     11      1.1  christos #include <openssl/proverr.h>
     12      1.1  christos #include "prov/digestcommon.h"
     13      1.1  christos 
     14      1.1  christos int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
     15  1.1.1.2  christos     size_t paramsz, unsigned long flags)
     16      1.1  christos {
     17      1.1  christos     OSSL_PARAM *p = NULL;
     18      1.1  christos 
     19      1.1  christos     p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE);
     20      1.1  christos     if (p != NULL && !OSSL_PARAM_set_size_t(p, blksz)) {
     21      1.1  christos         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
     22      1.1  christos         return 0;
     23      1.1  christos     }
     24      1.1  christos     p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE);
     25      1.1  christos     if (p != NULL && !OSSL_PARAM_set_size_t(p, paramsz)) {
     26      1.1  christos         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
     27      1.1  christos         return 0;
     28      1.1  christos     }
     29      1.1  christos     p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_XOF);
     30      1.1  christos     if (p != NULL
     31      1.1  christos         && !OSSL_PARAM_set_int(p, (flags & PROV_DIGEST_FLAG_XOF) != 0)) {
     32      1.1  christos         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
     33      1.1  christos         return 0;
     34      1.1  christos     }
     35      1.1  christos     p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_ALGID_ABSENT);
     36      1.1  christos     if (p != NULL
     37      1.1  christos         && !OSSL_PARAM_set_int(p, (flags & PROV_DIGEST_FLAG_ALGID_ABSENT) != 0)) {
     38      1.1  christos         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
     39      1.1  christos         return 0;
     40      1.1  christos     }
     41      1.1  christos     return 1;
     42      1.1  christos }
     43      1.1  christos 
     44      1.1  christos static const OSSL_PARAM digest_default_known_gettable_params[] = {
     45      1.1  christos     OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, NULL),
     46      1.1  christos     OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_SIZE, NULL),
     47      1.1  christos     OSSL_PARAM_int(OSSL_DIGEST_PARAM_XOF, NULL),
     48      1.1  christos     OSSL_PARAM_int(OSSL_DIGEST_PARAM_ALGID_ABSENT, NULL),
     49      1.1  christos     OSSL_PARAM_END
     50      1.1  christos };
     51      1.1  christos const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx)
     52      1.1  christos {
     53      1.1  christos     return digest_default_known_gettable_params;
     54      1.1  christos }
     55