Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 589580 Details for
Bug 811753
crypt() is broken in fips mode
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test source file
nss-example.c (text/x-csrc), 4.67 KB, created by
Paul Wouters
on 2012-06-05 16:45:15 UTC
(
hide
)
Description:
test source file
Filename:
MIME Type:
Creator:
Paul Wouters
Created:
2012-06-05 16:45:15 UTC
Size:
4.67 KB
patch
obsolete
>/* > * Demonstration program for hashing and MACs > */ > >#include <iostream> >using namespace std; >#include <string> >// #include <iostream.h> > >#include "pk11pub.h" >#include "nss.h" > >static void >printDigest(unsigned char *digest, unsigned int len) >{ > int i; > > cout << "length: " << len << endl; > for(i = 0;i < len;i++) printf("%02x ", digest[i]); > cout << endl; >} > >/* > * main > */ >int >main(int argc, const char *argv[]) >{ > int status = 0; > PK11SlotInfo *slot = 0; > PK11SymKey *key = 0; > PK11Context *context = 0; > unsigned char data[1024]; > unsigned char digest[1024]; /*Is there a way to tell how large the output is?*/ > unsigned int len, cnt; > SECStatus s; > >/* > SEC_OID_MD5 = 3, > SEC_OID_SHA1 = 4, > SEC_OID_SHA256 = 191, > SEC_OID_SHA384 = 192, > SEC_OID_SHA512 = 193, >*/ > SECOidTag algo[5]; > algo[0] = SEC_OID_MD5; > algo[1] = SEC_OID_SHA1; > algo[2] = SEC_OID_SHA256; > algo[3] = SEC_OID_SHA384; > algo[4] = SEC_OID_SHA512; > > printf("Before NSS_NoDB_Init\n"); > > /* Initialize NSS > * If your application code has already initialized NSS, you can skip it > * here. > * This code uses the simplest of the Init functions, which does not > * require a NSS database to exist > */ > NSS_NoDB_Init("."); > printf("Completed NSS_NoDB_Init\n"); > > /* Get a slot to use for the crypto operations */ > slot = PK11_GetInternalKeySlot(); > if (!slot) > { > cout << "GetInternalKeySlot failed" << endl; > status = 1; > goto done; > } > > /* > * Part 1 - Simple hashing > */ > cout << "Part 1 -- Simple hashing" << endl; > > /* Initialize data */ > memset(data, 0xbc, sizeof data); > > > for(cnt=0;cnt<4;cnt++) { > > printf("Trying algo SECOidTag: %d\n",algo[cnt]); > /* Create a context for hashing (digesting) */ > context = PK11_CreateDigestContext(algo[cnt]); > if (!context) { cout << "CreateDigestContext failed" << endl; goto done; } > > s = PK11_DigestBegin(context); > if (s != SECSuccess) { cout << "DigestBegin failed" << endl; goto done; } > > s = PK11_DigestOp(context, data, sizeof data); > if (s != SECSuccess) { cout << "DigestUpdate failed" << endl; goto done; } > > s = PK11_DigestFinal(context, digest, &len, sizeof digest); > if (s != SECSuccess) { cout << "DigestFinal failed" << endl; goto done; } > > /* Print digest */ > printDigest(digest, len); > > PK11_DestroyContext(context, PR_TRUE); > context = 0; > >} > > > > >#if 0 > > /* > * Part 2 - Hashing with included secret key > */ > cout << "Part 2 -- Hashing with included secret key" << endl; > > /* Initialize data */ > memset(data, 0xbc, sizeof data); > > /* Create a Key */ > key = PK11_KeyGen(slot, CKM_GENERIC_SECRET_KEY_GEN, 0, 128, 0); > if (!key) { cout << "Create key failed" << endl; goto done; } > > cout << (void *)key << endl; > > /* Create parameters for crypto context */ > /* NOTE: params must be provided, but may be empty */ > SECItem noParams; > noParams.type = siBuffer; > noParams.data = 0; > noParams.len = 0; > > /* Create context using the same slot as the key */ >// context = PK11_CreateDigestContext(SEC_OID_MD5); > context = PK11_CreateContextBySymKey(CKM_MD5, CKA_DIGEST, key, &noParams); > if (!context) { cout << "CreateDigestContext failed" << endl; goto done; } > > s = PK11_DigestBegin(context); > if (s != SECSuccess) { cout << "DigestBegin failed" << endl; goto done; } > > s = PK11_DigestKey(context, key); > if (s != SECSuccess) { cout << "DigestKey failed" << endl; goto done; } > > s = PK11_DigestOp(context, data, sizeof data); > if (s != SECSuccess) { cout << "DigestUpdate failed" << endl; goto done; } > > s = PK11_DigestFinal(context, digest, &len, sizeof digest); > if (s != SECSuccess) { cout << "DigestFinal failed" << endl; goto done; } > > /* Print digest */ > printDigest(digest, len); > > PK11_DestroyContext(context, PR_TRUE); > context = 0; > > /* > * Part 3 - MAC (with secret key) > */ > cout << "Part 3 -- MAC (with secret key)" << endl; > > /* Initialize data */ > memset(data, 0xbc, sizeof data); > > context = PK11_CreateContextBySymKey(CKM_MD5_HMAC, CKA_SIGN, key, &noParams); > if (!context) { cout << "CreateContextBySymKey failed" << endl; goto done; } > > s = PK11_DigestBegin(context); > if (s != SECSuccess) { cout << "DigestBegin failed" << endl; goto done; } > > s = PK11_DigestOp(context, data, sizeof data); > if (s != SECSuccess) { cout << "DigestOp failed" << endl; goto done; } > > s = PK11_DigestFinal(context, digest, &len, sizeof digest); > if (s != SECSuccess) { cout << "DigestFinal failed" << endl; goto done; } > > /* Print digest */ > printDigest(digest, len); > > PK11_DestroyContext(context, PR_TRUE); > context = 0; > >#endif > >done: > if (context) PK11_DestroyContext(context, PR_TRUE); /* freeit ?? */ > if (key) PK11_FreeSymKey(key); > if (slot) PK11_FreeSlot(slot); > > return status; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 811753
:
576902
|
584543
|
584565
|
584570
| 589580