random.c revision 65c4736d9c0ebc6d9b1d991593b55566909da9cd
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer unpublished work protected as such under copyright law. This work
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer contains proprietary, confidential, and trade secret information of
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer RSA Data Security, Inc. Use, disclosure or reproduction without the
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer express written authorization of RSA Data Security, Inc. is
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer prohibited.
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "global.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "bsafe2.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "bkey.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "balg.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "ainfotyp.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer#include "algobj.h"
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerint B_RandomInit
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer (algorithmObject, algorithmChooser, surrenderContext)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerB_ALGORITHM_OBJ algorithmObject;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerB_ALGORITHM_CHOOSER algorithmChooser;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerA_SURRENDER_CTX *surrenderContext;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer{
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer if (AlgorithmWrapCheck (THE_ALG_WRAP) != 0)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* Assume error is B_ALGORITHM_OBJ */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (BE_RANDOM_OBJ);
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (B_AlgorithmRandomInit
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer (&THE_ALG_WRAP->algorithm, algorithmChooser, surrenderContext));
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer}
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerint B_RandomUpdate (algorithmObject, input, inputLen, surrenderContext)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerB_ALGORITHM_OBJ algorithmObject;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerunsigned char *input;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerunsigned int inputLen;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerA_SURRENDER_CTX *surrenderContext;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer{
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer if (AlgorithmWrapCheck (THE_ALG_WRAP) != 0)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* Assume error is B_ALGORITHM_OBJ */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (BE_RANDOM_OBJ);
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (B_AlgorithmRandomUpdate
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer (&THE_ALG_WRAP->algorithm, input, inputLen, surrenderContext));
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer}
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerint B_GenerateRandomBytes
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer (algorithmObject, output, outputLen, surrenderContext)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerB_ALGORITHM_OBJ algorithmObject;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerunsigned char *output;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyerunsigned int outputLen;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael SawyerA_SURRENDER_CTX *surrenderContext;
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer{
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer if (AlgorithmWrapCheck (THE_ALG_WRAP) != 0)
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer /* Assume error is B_ALGORITHM_OBJ */
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (BE_RANDOM_OBJ);
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer return (B_AlgorithmGenerateRandomBytes
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer (&THE_ALG_WRAP->algorithm, output, outputLen, surrenderContext));
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer}
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer
02fdafbf53f712ee72ef50c4fa537f97082d8114Michael Sawyer