1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A/* minimum number of rounds we do, not including the per-user ones */ 1N/A * Public domain quotation courtesy of Project Gutenberg. 1N/A * Hamlet III.ii - 1517 bytes, including trailing NUL 1N/A * ANSI-C string constant concatenation is a requirement here. 1N/A "To be, or not to be,--that is the question:--\n" 1N/A "Whether 'tis nobler in the mind to suffer\n" 1N/A "The slings and arrows of outrageous fortune\n" 1N/A "Or to take arms against a sea of troubles,\n" 1N/A "And by opposing end them?--To die,--to sleep,--\n" 1N/A "No more; and by a sleep to say we end\n" 1N/A "The heartache, and the thousand natural shocks\n" 1N/A "That flesh is heir to,--'tis a consummation\n" 1N/A "Devoutly to be wish'd. To die,--to sleep;--\n" 1N/A "To sleep! perchance to dream:--ay, there's the rub;\n" 1N/A "For in that sleep of death what dreams may come,\n" 1N/A "When we have shuffled off this mortal coil,\n" 1N/A "Must give us pause: there's the respect\n" 1N/A "That makes calamity of so long life;\n" 1N/A "For who would bear the whips and scorns of time,\n" 1N/A "The oppressor's wrong, the proud man's contumely,\n" 1N/A "The pangs of despis'd love, the law's delay,\n" 1N/A "The insolence of office, and the spurns\n" 1N/A "That patient merit of the unworthy takes,\n" 1N/A "When he himself might his quietus make\n" 1N/A "With a bare bodkin? who would these fardels bear,\n" 1N/A "To grunt and sweat under a weary life,\n" 1N/A "But that the dread of something after death,--\n" 1N/A "The undiscover'd country, from whose bourn\n" 1N/A "No traveller returns,--puzzles the will,\n" 1N/A "And makes us rather bear those ills we have\n" 1N/A "Than fly to others that we know not of?\n" 1N/A "Thus conscience does make cowards of us all;\n" 1N/A "And thus the native hue of resolution\n" 1N/A "Is sicklied o'er with the pale cast of thought;\n" 1N/A "And enterprises of great pith and moment,\n" 1N/A "With this regard, their currents turn awry,\n" 1N/A "And lose the name of action.--Soft you now!\n" 1N/A "The fair Ophelia!--Nymph, in thy orisons\n" 1N/A "Be all my sins remember'd.\n";
1N/A/* ------------------------------------------------------------------ */ 1N/A bit_num %=
128;
/* keep this bounded for convenience */ 1N/A /* return the value of bit N from the digest */ 1N/A "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1N/A * get the integer value after rounds= where ever it occurs in the string. 1N/A * if the last char after the int is a , or $ that is fine anything else is an 1N/A * An error occurred or there is non-numeric stuff at the end 1N/A * which isn't one of the crypt(3c) special chars ',' or '$' 1N/A !(*e ==
'\0' || *e ==
',' || *e ==
'$')) {
1N/A "crypt_sunmd5: invalid rounds specification \"%s\"", s);
1N/A "crypt_sunmd5: invalid parameter %s",
params[i]);
1N/A * If the config file has a higher value for rounds= than what 1N/A * was in the old salt use that, otherwise keep what was in the 1N/A /* put all the sensitive data in a struct */ 1N/A int s7shift;
/* shift for shift_7 creation, vals 0..7 */ 1N/A int bit_a;
/* single bit for cointoss */ 1N/A int bit_b;
/* single bit for cointoss */ 1N/A * Extract the puresalt (if it exists) from the existing salt string 1N/A * $md5[,rounds=%d]$<puresalt>$<optional existing encoding> 1N/A /* initialise the context */ 1N/A /* update with the (hopefully entropic) plaintext */ 1N/A /* update with the (publically known) salt */ 1N/A /* compute the digest */ 1N/A * now to delay high-speed md5 implementations that have stuff 1N/A * like code inlining, loops unrolled and table lookup /* re-initialise the context */ /* update with the previous digest */ /* populate the shift schedules for use later */ for (i = 0; i <
16; i++) {
/* offset 3 -> occasionally span more than 1 int32 fetch */ /* populate indirect_4 with 4bit values extracted from digest */ for (i = 0; i <
16; i++) {
/* shift the digest byte and extract four bits */ * populate indirect_7 with 7bit values from digest for (i = 0; i <
16; i++) {
/* shift the digest byte and extract seven bits */ * use the 7bit values to indirect into digest, * and create two 8bit values from the results. for (i = 0; i <
8; i++) {
/* shall we utilise the top or bottom 7 bits? */ /* extract two data.digest bits */ for (i = 0; i <
15; i++) {
for (i = 0; i <
15; i++) {
/* xor a coin-toss; if true, mix-in the constant phrase */ (
void)
printf(
"mixing constant_phrase\n");
/* digest a decimal sprintf of the current roundcount */ for (i = 0; i <
16; i++) {
/* tidy up after ourselves */