summaryrefslogtreecommitdiff
path: root/lib/freebl/loader.c
diff options
context:
space:
mode:
authorRobert Relyea <rrelyea@redhat.com>2016-02-18 07:44:58 -0800
committerRobert Relyea <rrelyea@redhat.com>2016-02-18 07:44:58 -0800
commit4f2f5fae9d8548e6bdd72e800f1ad1e744814be1 (patch)
tree339642fd83cccc83d259e8b8268ffcede6763452 /lib/freebl/loader.c
parent0430632bc275b4be8104482168a8777b8d2daa3f (diff)
downloadnss-hg-4f2f5fae9d8548e6bdd72e800f1ad1e744814be1.tar.gz
Bug 1181814 - Pick up FIPS-140 certification work done by Red Hat, r=kaie, emaldona
- Includes modifications submitted by kaie and emaldona, r=rrelyea
Diffstat (limited to 'lib/freebl/loader.c')
-rw-r--r--lib/freebl/loader.c95
1 files changed, 5 insertions, 90 deletions
diff --git a/lib/freebl/loader.c b/lib/freebl/loader.c
index 33075c19f..b3fd2cd7d 100644
--- a/lib/freebl/loader.c
+++ b/lib/freebl/loader.c
@@ -10,93 +10,7 @@
#include "prerror.h"
#include "prinit.h"
#include "prenv.h"
-
-static const char* default_name =
- SHLIB_PREFIX"freebl"SHLIB_VERSION"."SHLIB_SUFFIX;
-
-/* getLibName() returns the name of the library to load. */
-
-#if defined(SOLARIS) && defined(__sparc)
-#include <stddef.h>
-#include <strings.h>
-#include <sys/systeminfo.h>
-
-
-#if defined(NSS_USE_64)
-
-const static char fpu_hybrid_shared_lib[] = "libfreebl_64fpu_3.so";
-const static char int_hybrid_shared_lib[] = "libfreebl_64int_3.so";
-const static char non_hybrid_shared_lib[] = "libfreebl_64fpu_3.so";
-
-const static char int_hybrid_isa[] = "sparcv9";
-const static char fpu_hybrid_isa[] = "sparcv9+vis";
-
-#else
-
-const static char fpu_hybrid_shared_lib[] = "libfreebl_32fpu_3.so";
-const static char int_hybrid_shared_lib[] = "libfreebl_32int64_3.so";
-/* This was for SPARC V8, now obsolete. */
-const static char *const non_hybrid_shared_lib = NULL;
-
-const static char int_hybrid_isa[] = "sparcv8plus";
-const static char fpu_hybrid_isa[] = "sparcv8plus+vis";
-
-#endif
-
-static const char *
-getLibName(void)
-{
- char * found_int_hybrid;
- char * found_fpu_hybrid;
- long buflen;
- char buf[256];
-
- buflen = sysinfo(SI_ISALIST, buf, sizeof buf);
- if (buflen <= 0)
- return NULL;
- /* sysinfo output is always supposed to be NUL terminated, but ... */
- if (buflen < sizeof buf)
- buf[buflen] = '\0';
- else
- buf[(sizeof buf) - 1] = '\0';
- /* The ISA list is a space separated string of names of ISAs and
- * ISA extensions, in order of decreasing performance.
- * There are two different ISAs with which NSS's crypto code can be
- * accelerated. If both are in the list, we take the first one.
- * If one is in the list, we use it, and if neither then we use
- * the base unaccelerated code.
- */
- found_int_hybrid = strstr(buf, int_hybrid_isa);
- found_fpu_hybrid = strstr(buf, fpu_hybrid_isa);
- if (found_fpu_hybrid &&
- (!found_int_hybrid ||
- (found_int_hybrid - found_fpu_hybrid) >= 0)) {
- return fpu_hybrid_shared_lib;
- }
- if (found_int_hybrid) {
- return int_hybrid_shared_lib;
- }
- return non_hybrid_shared_lib;
-}
-
-#elif defined(HPUX) && !defined(NSS_USE_64) && !defined(__ia64)
-#include <unistd.h>
-
-/* This code tests to see if we're running on a PA2.x CPU.
-** It returns true (1) if so, and false (0) otherwise.
-*/
-static const char *
-getLibName(void)
-{
- long cpu = sysconf(_SC_CPU_VERSION);
- return (cpu == CPU_PA_RISC2_0)
- ? "libfreebl_32fpu_3.sl"
- : "libfreebl_32int_3.sl" ;
-}
-#else
-/* default case, for platforms/ABIs that have only one freebl shared lib. */
-static const char * getLibName(void) { return default_name; }
-#endif
+#include "blname.c"
#include "prio.h"
#include "prprf.h"
@@ -106,7 +20,7 @@ static const char * getLibName(void) { return default_name; }
static const char *NameOfThisSharedLib =
SHLIB_PREFIX"softokn"SOFTOKEN_SHLIB_VERSION"."SHLIB_SUFFIX;
-static PRLibrary* blLib;
+static PRLibrary* blLib = NULL;
#define LSB(x) ((x)&0xff)
#define MSB(x) ((x)>>8)
@@ -149,12 +63,12 @@ freebl_LoadDSO( void )
}
}
#ifdef DEBUG
- {
+ if (blLib) {
PRStatus status = PR_UnloadLibrary(blLib);
PORT_Assert(PR_SUCCESS == status);
}
#else
- PR_UnloadLibrary(blLib);
+ if (blLib) PR_UnloadLibrary(blLib);
#endif
}
return PR_FAILURE;
@@ -2184,3 +2098,4 @@ ChaCha20Poly1305_Open(const ChaCha20Poly1305Context *ctx,
ctx, output, outputLen, maxOutputLen, input, inputLen,
nonce, nonceLen, ad, adLen);
}
+