fips.c (1739B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#include "config.h" 21#include "guacamole/fips.h" 22 23/* If OpenSSL is available, include header for version numbers */ 24#ifdef ENABLE_SSL 25 #include <openssl/opensslv.h> 26 27 /* OpenSSL versions prior to 0.9.7e did not have FIPS support */ 28 #if !defined(OPENSSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x00090705f) 29 #define GUAC_FIPS_ENABLED 0 30 31 /* OpenSSL 3+ uses EVP_default_properties_is_fips_enabled() */ 32 #elif defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) 33 #include <openssl/evp.h> 34 #define GUAC_FIPS_ENABLED EVP_default_properties_is_fips_enabled(NULL) 35 36 /* For OpenSSL versions between 0.9.7e and 3.0, use FIPS_mode() */ 37 #else 38 #include <openssl/crypto.h> 39 #define GUAC_FIPS_ENABLED FIPS_mode() 40 #endif 41 42/* FIPS support does not exist if OpenSSL is not available. */ 43#else 44#define GUAC_FIPS_ENABLED 0 45#endif 46 47int guac_fips_enabled() { 48 49 return GUAC_FIPS_ENABLED; 50 51}