Commit 71615470 authored by gcasto@chromium.org's avatar gcasto@chromium.org

Add additional files required for fips181 compliation

This module still doesn't compile as there are certain dependencies
(mainly random number generator) that need to be replaced first, but
all necessary third_party code should now included.

BUG=165318

Review URL: https://codereview.chromium.org/285263002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271566 0039d316-1c4b-4281-b951-d872f2087c98
parent e7eaa2b8
This diff is collapsed.
/*
** Copyright (c) 1999, 2000, 2001, 2002, 2003
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1.Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2.Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3.The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef APG_CONVERT_H
#define APG_CONVERT_H 1
void decapitalize (char *word);
#ifndef APGBFM
void capitalize (char *syllable);
void numerize (char *syllable);
void specialize (char *syllable);
void symb2name(char * syllable, char * h_syllable);
char* spell_word(char * word, char * spelled_word);
#endif /* APGBFM */
#endif /* APG_CONVERT_H */
...@@ -16,8 +16,17 @@ ...@@ -16,8 +16,17 @@
], ],
}, },
'sources': [ 'sources': [
'convert.cc',
'convert.h',
'fips181.cc', 'fips181.cc',
'fips181.h', 'fips181.h',
'owntypes.h',
'randpass.cc',
'randpass.h',
'smbl.h',
],
'dependencies': [
'../../base/base.gyp:base',
], ],
}, },
], ],
......
/*
** Copyright (c) 1999, 2000, 2001, 2002, 2003
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1.Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2.Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3.The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef APG_OWN_TYPES_H
#define APG_OWN_TYPES_H 1
typedef unsigned int UINT;
typedef unsigned short USHORT;
typedef short int SHORT;
typedef int boolean;
typedef unsigned long int UINT32;
#define TRUE 1
#define FALSE 0
#define APG_MAX_PASSWORD_LENGTH 255
#endif /* APG_OWN_TYPES_H */
/*
** Copyright (c) 1999, 2000, 2001, 2002, 2003
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1.Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2.Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3.The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
** randpass.c - Random password generation module of PWGEN program
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
#include <pwd.h>
#endif
#include <unistd.h>
#include "randpass.h"
#include "owntypes.h"
#include "smbl.h"
/*
** gen_rand_pass - generates random password of specified type
** INPUT:
** char * - password string.
** int - minimum password length.
** int - maximum password length.
** unsigned int - password generation mode.
** OUTPUT:
** int - password length or -1 on error.
** NOTES:
** none.
*/
int
gen_rand_pass (char *password_string, int minl, int maxl, unsigned int pass_mode)
{
int i = 0;
int j = 0;
int length = 0;
char *str_pointer;
int random_weight[94];
int max_weight = 0;
int max_weight_element_number = 0;
if (minl > APG_MAX_PASSWORD_LENGTH || maxl > APG_MAX_PASSWORD_LENGTH ||
minl < 1 || maxl < 1 || minl > maxl)
return (-1);
for (i = 0; i <= 93; i++) random_weight[i] = 0;
length = minl + randint(maxl-minl+1);
str_pointer = password_string;
for (i = 0; i < length; i++)
{
/* Asign random weight in weight array if mode is present*/
for (j = 0; j <= 93 ; j++)
if ( ( (pass_mode & smbl[j].type) > 0) &&
!( (S_RS & smbl[j].type) > 0))
random_weight[j] = 1 + randint(20000);
j = 0;
/* Find an element with maximum weight */
for (j = 0; j <= 93; j++)
if (random_weight[j] > max_weight)
{
max_weight = random_weight[j];
max_weight_element_number = j;
}
/* Get password symbol */
*str_pointer = smbl[max_weight_element_number].ch;
str_pointer++;
max_weight = 0;
max_weight_element_number = 0;
for (j = 0; j <= 93; j++) random_weight[j] = 0;
}
*str_pointer = 0;
return (length);
}
/*
** gen_rand_symbol - generates random password of specified type
** INPUT:
** char * - symbol.
** unsigned int - symbol type.
** OUTPUT:
** int - password length or -1 on error.
** NOTES:
** none.
*/
int
gen_rand_symbol (char *symbol, unsigned int mode)
{
int j = 0;
char *str_pointer;
int random_weight[94];
int max_weight = 0;
int max_weight_element_number = 0;
for (j = 0; j <= 93; j++) random_weight[j] = 0;
str_pointer = symbol;
j = 0;
/* Asign random weight in weight array if mode is present*/
for (j = 0; j <= 93 ; j++)
if ( ( (mode & smbl[j].type) > 0) &&
!( (S_RS & smbl[j].type) > 0))
random_weight[j] = 1 + randint(20000);
j = 0;
/* Find an element with maximum weight */
for (j = 0; j <= 93; j++)
if (random_weight[j] > max_weight)
{
max_weight = random_weight[j];
max_weight_element_number = j;
}
/* Get password symbol */
*str_pointer = smbl[max_weight_element_number].ch;
max_weight = 0;
max_weight_element_number = 0;
return (0);
}
/*
** is_restricted_symbol - detcts if symbol is restricted rigt now
** INPUT:
** char - symbol.
** OUTPUT:
** int - 0 - not restricted
** 1 - restricted
** NOTES:
** none.
*/
int
is_restricted_symbol (char symbol)
{
int j = 0;
for (j = 0; j <= 93 ; j++)
if (symbol == smbl[j].ch)
if ((S_RS & smbl[j].type) > 0)
return(1);
return(0);
}
/*
** Copyright (c) 1999, 2000, 2001, 2002, 2003
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1.Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2.Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3.The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
** randpass.h
*/
#ifndef APG_RANDPASS_H
#define APG_RANDPASS_H 1
#ifndef APG_RND_H
#include "rnd.h"
#endif
#ifndef APG_OWN_TYPES_H
#include "owntypes.h"
#endif
#define S_NB 0x01 /* Numeric */
#define S_SS 0x02 /* Special */
#define S_CL 0x04 /* Capital */
#define S_SL 0x08 /* Small */
#define S_RS 0x10 /* Restricted Symbol*/
struct sym
{
char ch;
USHORT type;
};
/* char gen_symbol(unsigned short int symbol_class); */
extern int gen_rand_pass(char* password_string, int minl,
int maxl, unsigned int pass_mode);
extern int gen_rand_symbol (char *symbol, unsigned int mode);
extern int is_restricted_symbol (char symbol);
#endif /* RANDPASS_H */
/*
** Copyright (c) 1999, 2000, 2001, 2002, 2003
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1.Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2.Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3.The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
** OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
** GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef APG_SMBL_H
#define APG_SMBL_H 1
struct sym smbl[94] =
{
{'a', S_SL}, {'b', S_SL}, {'c', S_SL}, {'d', S_SL}, {'e', S_SL}, {'f', S_SL},
{'g', S_SL}, {'h', S_SL}, {'i', S_SL}, {'j', S_SL}, {'k', S_SL}, {'l', S_SL},
{'m', S_SL}, {'n', S_SL}, {'o', S_SL}, {'p', S_SL}, {'q', S_SL}, {'r', S_SL},
{'s', S_SL}, {'t', S_SL}, {'u', S_SL}, {'v', S_SL}, {'w', S_SL}, {'x', S_SL},
{'y', S_SL}, {'z', S_SL}, {'A', S_CL}, {'B', S_CL}, {'C', S_CL}, {'D', S_CL},
{'E', S_CL}, {'F', S_CL}, {'G', S_CL}, {'H', S_CL}, {'I', S_CL}, {'J', S_CL},
{'K', S_CL}, {'L', S_CL}, {'M', S_CL}, {'N', S_CL}, {'O', S_CL}, {'P', S_CL},
{'Q', S_CL}, {'R', S_CL}, {'S', S_CL}, {'T', S_CL}, {'U', S_CL}, {'V', S_CL},
{'W', S_CL}, {'X', S_CL}, {'Y', S_CL}, {'Z', S_CL}, {'1', S_NB}, {'2', S_NB},
{'3', S_NB}, {'4', S_NB}, {'5', S_NB}, {'6', S_NB}, {'7', S_NB}, {'8', S_NB},
{'9', S_NB}, {'0', S_NB}, {33 , S_SS}, {34 , S_SS}, {35 , S_SS}, {36 , S_SS},
{37 , S_SS}, {38 , S_SS}, {39 , S_SS}, {40 , S_SS}, {41 , S_SS}, {42 , S_SS},
{43 , S_SS}, {44 , S_SS}, {45 , S_SS}, {46 , S_SS}, {47 , S_SS}, {58 , S_SS},
{59 , S_SS}, {60 , S_SS}, {61 , S_SS}, {62 , S_SS}, {63 , S_SS}, {64 , S_SS},
{91 , S_SS}, {92 , S_SS}, {93 , S_SS}, {94 , S_SS}, {95 , S_SS}, {96 , S_SS},
{123, S_SS}, {124, S_SS}, {125, S_SS}, {126, S_SS}
};
#endif /* APG_SMBL_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment