fips/Makefile: HP-UX-specific update.
[openssl.git] / fips / fips_utl.h
index f64a35d8943e1a7409e5170cb5bd1a48254662af..6cb58094b8321d40335afe9cf1992c93bc8dc545 100644 (file)
@@ -1,5 +1,5 @@
 /* ====================================================================
- * Copyright (c) 2007 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,6 +66,8 @@ void PrintValue(char *tag, unsigned char *val, int len);
 void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode);
 void fips_algtest_init(void);
 void do_entropy_stick(void);
+int fips_strncasecmp(const char *str1, const char *str2, size_t n);
+int fips_strcasecmp(const char *str1, const char *str2);
 
 static int no_err;
 
@@ -134,7 +136,7 @@ void do_entropy_stick(void)
 void fips_algtest_init(void)
        {
        fips_algtest_init_nofips();
-       if (!FIPS_mode_set(1))
+       if (!FIPS_module_mode_set(1))
                {
                fprintf(stderr, "Error entering FIPS mode\n");
                exit(1);
@@ -420,3 +422,32 @@ void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode)
 #endif
     }
 
+/* Not all platforms support strcasecmp and strncasecmp: implement versions
+ * in here to avoid need to include them in the validated module. Taken
+ * from crypto/o_str.c written by Richard Levitte (richard@levitte.org)
+ */
+
+int fips_strncasecmp(const char *str1, const char *str2, size_t n)
+       {
+       while (*str1 && *str2 && n)
+               {
+               int res = toupper(*str1) - toupper(*str2);
+               if (res) return res < 0 ? -1 : 1;
+               str1++;
+               str2++;
+               n--;
+               }
+       if (n == 0)
+               return 0;
+       if (*str1)
+               return 1;
+       if (*str2)
+               return -1;
+       return 0;
+       }
+
+int fips_strcasecmp(const char *str1, const char *str2)
+       {
+       return fips_strncasecmp(str1, str2, (size_t)-1);
+       }
+