summaryrefslogtreecommitdiff
path: root/lib/freebl/shvfy.c
diff options
context:
space:
mode:
authorRobert Relyea <rrelyea@redhat.com>2016-03-14 19:35:35 +0100
committerRobert Relyea <rrelyea@redhat.com>2016-03-14 19:35:35 +0100
commit9ee2593072fddf6dcf5b282ca11459d69178263f (patch)
treecbbad6badf9069b745c713ed7c175218165c7729 /lib/freebl/shvfy.c
parentf92092976980b5b0194978b657f26ca5526ef71b (diff)
downloadnss-hg-9ee2593072fddf6dcf5b282ca11459d69178263f.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/shvfy.c')
-rw-r--r--lib/freebl/shvfy.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/freebl/shvfy.c b/lib/freebl/shvfy.c
index ad64a26a2..5ff08b158 100644
--- a/lib/freebl/shvfy.c
+++ b/lib/freebl/shvfy.c
@@ -16,6 +16,7 @@
#include "prmem.h"
#include "hasht.h"
#include "pqg.h"
+#include "blapii.h"
/*
* Most modern version of Linux support a speed optimization scheme where an
@@ -273,8 +274,10 @@ readItem(PRFileDesc *fd, SECItem *item)
return SECSuccess;
}
-PRBool
-BLAPI_SHVerify(const char *name, PRFuncPtr addr)
+static PRBool blapi_SHVerifyFile(const char *shName, PRBool self);
+
+static PRBool
+blapi_SHVerify(const char *name, PRFuncPtr addr, PRBool self)
{
PRBool result = PR_FALSE; /* if anything goes wrong,
* the signature does not verify */
@@ -283,7 +286,7 @@ BLAPI_SHVerify(const char *name, PRFuncPtr addr)
if (!shName) {
goto loser;
}
- result = BLAPI_SHVerifyFile(shName);
+ result = blapi_SHVerifyFile(shName, self);
loser:
if (shName != NULL) {
@@ -294,8 +297,20 @@ loser:
}
PRBool
+BLAPI_SHVerify(const char *name, PRFuncPtr addr)
+{
+ return blapi_SHVerify(name, addr, PR_FALSE);
+}
+
+PRBool
BLAPI_SHVerifyFile(const char *shName)
{
+ return blapi_SHVerifyFile(shName, PR_FALSE);
+}
+
+static PRBool
+blapi_SHVerifyFile(const char *shName, PRBool self)
+{
char *checkName = NULL;
PRFileDesc *checkFD = NULL;
PRFileDesc *shFD = NULL;
@@ -320,6 +335,12 @@ BLAPI_SHVerifyFile(const char *shName)
hash.data = hashBuf;
hash.len = sizeof(hashBuf);
+ /* If our integrity check was never ran or failed, fail any other
+ * integrity checks to prevent any token going into FIPS mode. */
+ if (!self && (BL_FIPSEntryOK(PR_FALSE) != SECSuccess)) {
+ return PR_FALSE;
+ }
+
if (!shName) {
goto loser;
}
@@ -504,5 +525,5 @@ BLAPI_VerifySelf(const char *name)
*/
return PR_TRUE;
}
- return BLAPI_SHVerify(name, (PRFuncPtr) decodeInt);
+ return blapi_SHVerify(name, (PRFuncPtr) decodeInt, PR_TRUE);
}