亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lucas.c

?? IBE是一種非對稱密碼技術
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* Copyright 2005-2006, Voltage Security, all rights reserved.
 */

#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "mpint.h"
#include "prime.h"
#include "errorctx.h"

/* Find the Lucas Test D value (called D in X9.31). It is a number from
 * the sequence
 *   5, -7, 9, -11, 13, -15, 17, ...
 * It is the smallest from the set of numbers for which the Jacobi
 * is -1.
 * <p>The function will check to see if Jacobi (5) is -1. If not, it
 * will try -7 (actually primeCandidate - 7). If -7 fails, it will try
 * 9. And so on. However, the function will not try every possible
 * number. At some point it will give up. The likelihood of giving up
 * in the real world is extremely small, but the code is there to
 * prevent a "near-infinite" loop. See the function to find out where
 * it gives up. If the function gives up, it will return 0 and set
 * valueFound to 0 (no/false).
 * <p>What will almost certainly happen every time in the real world,
 * is that the function will find D (the vast majority of the time it
 * will be 5 or -7) and set valueFound to 1 (yes/true).
 * <p>The function also calls for some temp MpInts, just so we don't
 * create and destroy MpInts again and again.
 *
 * @param primeCandidate
 * @param DValue The created mpInt that this function will set with the
 * found D value.
 * @param temp1
 * @param temp2
 * @param valueFound The address where the routine will deposit an
 * unsigned int indicating whether it found a D or not.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV FindLucasDValue VOLT_PROTO_LIST ((
   VoltMpInt *primeCandidate,
   VoltMpInt *DValue,
   VoltMpInt *temp1,
   VoltMpInt *temp2,
   unsigned int *valueFound
));

/* Find the Jacobi (a/n).
 * <p>This function follows the algorithm outlined in X9.42.
 * <p>The function will set the int at jacobi to 0, +1, or -1.
 *
 * @param nVal
 * @param aVal The number for which the Jacobi is requested.
 * @param jacobi The address where the routine will deposit an int, the
 * result, either 0, +1, or -1.
 * @return an int, 0 if the function completed successfully or a
 * non-zero error code.
 */
static int VOLT_CALLING_CONV FindJacobi VOLT_PROTO_LIST ((
   VoltMpInt *aVal,
   VoltMpInt *nVal,
   VoltMpInt *temp1,
   VoltMpInt *temp2,
   int *jacobi
));

int VoltLucasTest (
   VoltMpInt *primeCandidate,
   unsigned int *isPrime
   )
{
  int status, getZero;
  unsigned int index, bitLen, valueFound, getBit;
  VoltMpIntCtx *mpCtx = (VoltMpIntCtx *)(primeCandidate->mpCtx);
  VoltMpInt *NPlus1 = (VoltMpInt *)0;
  VoltMpInt *DValue = (VoltMpInt *)0;
  VoltMpInt *UVal = (VoltMpInt *)0;
  VoltMpInt *VVal = (VoltMpInt *)0;
  VoltMpInt *newU = (VoltMpInt *)0;
  VoltMpInt *newV = (VoltMpInt *)0;
  VOLT_DECLARE_ERROR_TYPE (errorType)
  VOLT_DECLARE_FNCT_LINE (fnctLine)

  /* Init the isPrime return to not prime, change it if it passes the
   * tests.
   */
  *isPrime = 0;

  do
  {
    VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)

    /* In X9.31, the candidate is called N.
     * We need N + 1, we'll want the bit length of this value, and
     * later on, the actual work in each iteration of the loop will
     * depend on each of the bits of N + 1.
     */
    VOLT_SET_ERROR_TYPE (errorType, 0)
    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &NPlus1);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->IntToMpInt (0, 1, NPlus1);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->Add (primeCandidate, NPlus1, NPlus1);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->GetBitLength (NPlus1, &bitLen);
    if (status != 0)
      break;

    /* Find D. It is from the sequence
     *   5, -7, 9, -11, 13, -15, 17, ...
     * It is the smallest from the set of numbers for which the Jacobi
     * is -1. We'll call FindLucasDValue to do that. It needs a created
     * but empty mpInt.
     * See the comments on the FindLucasDValue function for more
     * info.
     * The FindD function requires a couple temp variables. Use U and V.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &DValue);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &UVal);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &VVal);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = FindLucasDValue (
      primeCandidate, DValue, UVal, VVal, &valueFound);
    if (status != 0)
      break;

    /* If we reach this point and valueFound is 0 (status is 0), we
     * need to give up on this candidate. isPrime was initialized to
     * false.
     */
    if (valueFound == 0)
      break;

    /* For each bit in N + 1, compute U and V.
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &newU);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->CreateMpInt ((Pointer)mpCtx, &newV);
    if (status != 0)
      break;

    /* Step 3, initialize U to 1 and V to P (which is fixed at 1).
     */
    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->IntToMpInt (0, 1, UVal);
    if (status != 0)
      break;

    VOLT_SET_FNCT_LINE (fnctLine)
    status = mpCtx->IntToMpInt (0, 1, VVal);
    if (status != 0)
      break;

    for (index = bitLen - 1; index > 0; --index)
    {
      /* Step 4: First, newU = UV mod N
       *                newV = (V^2 + DU^2) / 2  mod N
       * Do newV first so we can use newU as a temp variable.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Square (UVal, newU);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->ModReduce (newU, primeCandidate, newV);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Multiply (DValue, newV, newU);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Square (VVal, newV);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Add (newV, newU, newU);
      if (status != 0)
        break;

      /* If newU is now even, divide by 2 by shifting right by 1 bit.
       * If newU is odd, add modulus (primeCandidate) and then divide
       * by 2.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->GetBit (newU, 0, &getBit);
      if (status != 0)
        break;

      if (getBit == 1)
      {
        VOLT_SET_FNCT_LINE (fnctLine)
        status = mpCtx->Add (primeCandidate, newU, newU);
        if (status != 0)
          break;
      }

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->ShiftRightBits (newU, 1);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->ModReduce (newU, primeCandidate, newV);
      if (status != 0)
        break;

      /* Now compute the newU.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Multiply (UVal, VVal, newU);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->ModReduce (newU, primeCandidate, UVal);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->MpIntToMpInt (newV, VVal);
      if (status != 0)
        break;

      /* Get the current bit from N + 1 (index is "off" by one so we
       * can have a loop limit of 0).
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->GetBit (NPlus1, index - 1, &getBit);
      if (status != 0)
        break;

      /* If this bit is 0, we're done for this loop.
       */
      if (getBit == 0)
        continue;

      /* If this bit is set, we need to continue
       * Step 4: newU = (U + V) / 2 mod N
       *         newV = (V + DU) / 2 mod N
       * Once again, do newV first so we can use newU as a temp
       * variable.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Multiply (DValue, UVal, newU);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->Add (VVal, newU, newU);
      if (status != 0)
        break;

      /* If newU is now even, divide by 2 by shifting right by 1 bit.
       * If newU is odd, add modulus (primeCandidate) and then divide
       * by 2.
       */
      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->GetBit (newU, 0, &getBit);
      if (status != 0)
        break;

      if (getBit == 1)
      {
        VOLT_SET_FNCT_LINE (fnctLine)
        status = mpCtx->Add (primeCandidate, newU, newU);
        if (status != 0)
          break;
      }

      VOLT_SET_FNCT_LINE (fnctLine)
      status = mpCtx->ShiftRightBits (newU, 1);
      if (status != 0)
        break;

      VOLT_SET_FNCT_LINE (fnctLine)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一二三四高清不卡| 美脚の诱脚舐め脚责91| 日韩av中文字幕一区二区| 国产精品一卡二卡| 欧美在线小视频| 国产欧美精品一区| 日本怡春院一区二区| www.久久精品| 久久九九99视频| 日本特黄久久久高潮| 欧美午夜精品久久久久久超碰| 精品美女被调教视频大全网站| 午夜影视日本亚洲欧洲精品| 99re视频精品| 亚洲国产成人午夜在线一区| 久久成人精品无人区| 69堂精品视频| 日本三级亚洲精品| 欧美猛男男办公室激情| 一区二区视频在线看| 国产成人综合自拍| 国产日韩一级二级三级| 国产久卡久卡久卡久卡视频精品| 69久久夜色精品国产69蝌蚪网| 亚洲自拍偷拍欧美| 色呦呦网站一区| 亚洲欧美日韩一区二区三区在线观看| 国产91对白在线观看九色| 欧美tk—视频vk| 免费成人在线观看| 日韩一区二区在线免费观看| 婷婷六月综合网| 在线成人av影院| 免费在线看成人av| 日韩精品综合一本久道在线视频| 蜜臀久久久99精品久久久久久| 91麻豆精品久久久久蜜臀| 日韩精品久久理论片| 欧美一级搡bbbb搡bbbb| 麻豆精品蜜桃视频网站| 精品成人一区二区三区| 韩国理伦片一区二区三区在线播放| 久久综合资源网| 丁香一区二区三区| 日韩理论电影院| 欧美日韩国产大片| 精品一区二区三区久久| 精品美女在线观看| 不卡在线视频中文字幕| 亚洲一区二区欧美| 91精品国产欧美一区二区成人 | 国产精品性做久久久久久| 337p日本欧洲亚洲大胆精品| 懂色av一区二区夜夜嗨| 亚洲人成网站色在线观看| 欧美亚洲一区二区在线观看| 免费日本视频一区| 亚洲国产精品高清| 欧美性色黄大片手机版| 精品制服美女久久| 日韩理论片在线| 日韩三级视频中文字幕| av一区二区三区四区| 午夜久久久久久久久久一区二区| 精品sm在线观看| 色悠悠亚洲一区二区| 蜜臀av一区二区三区| 国产精品护士白丝一区av| 7777精品伊人久久久大香线蕉经典版下载 | 日韩国产欧美在线视频| 欧美高清在线精品一区| 777欧美精品| www.99精品| 乱一区二区av| 亚洲一区二区三区四区五区中文 | 久久99国产精品尤物| 亚洲欧美中日韩| 欧美大片在线观看一区| 91网页版在线| 国产精品一区二区免费不卡 | 国产精品久久夜| 日韩一区二区三免费高清| 不卡视频一二三四| 久久99久久久欧美国产| 亚洲日本在线a| 久久精品免费在线观看| 欧美图区在线视频| aaa国产一区| 国产高清不卡一区| 视频一区中文字幕| 亚洲天堂免费看| 中文字幕av一区二区三区高| 欧美一区二区久久| 欧美日韩一区成人| 色诱视频网站一区| av电影在线观看完整版一区二区| 国产一区二区三区在线观看精品| 日韩专区在线视频| 亚洲一本大道在线| 亚洲精品日韩综合观看成人91| 国产欧美精品国产国产专区 | 国产麻豆精品视频| 免费av网站大全久久| 午夜视频一区二区三区| 亚洲欧美日韩久久精品| 亚洲天堂免费看| 综合电影一区二区三区| 国产精品麻豆99久久久久久| 久久久99精品久久| 欧美精品一区二区高清在线观看| 日韩一级二级三级| 日韩亚洲欧美在线观看| 日韩欧美中文字幕精品| 精品理论电影在线观看 | 欧美少妇xxx| 欧美精品一级二级| 777午夜精品免费视频| 欧美一级免费大片| 日韩一级成人av| 26uuu亚洲| 国产精品久久久久久久久免费桃花| 国产三级精品三级| 亚洲色图欧美在线| 一区二区三区免费看视频| 亚洲午夜免费电影| 日韩黄色片在线观看| 久久精品二区亚洲w码| 韩国v欧美v日本v亚洲v| 国产91丝袜在线观看| 成人av动漫在线| 欧美中文字幕亚洲一区二区va在线| 欧美性猛交一区二区三区精品| 欧美日韩黄视频| 日韩三区在线观看| 亚洲国产精品成人综合 | 中国色在线观看另类| 亚洲乱码中文字幕综合| 亚洲成人免费视频| 久久成人18免费观看| jlzzjlzz欧美大全| 欧美调教femdomvk| 国产区在线观看成人精品| 亚洲色图清纯唯美| 久久99国产精品久久99| 成人免费的视频| 欧美日韩国产成人在线免费| 久久久99免费| 一区二区三区四区在线免费观看| 日韩va亚洲va欧美va久久| 国产不卡视频一区二区三区| 日本高清不卡视频| 欧美成人精品3d动漫h| 国产精品夫妻自拍| 日本欧美在线看| 99精品视频中文字幕| 欧美成人免费网站| 亚洲欧美日本韩国| 国产最新精品免费| 欧美精品在线观看播放| 国产精品卡一卡二| 奇米色一区二区| 色婷婷国产精品综合在线观看| 日韩视频一区二区在线观看| 亚洲男同性恋视频| 国内精品伊人久久久久影院对白| 91一区二区在线| 久久人人爽人人爽| 午夜精品在线看| 91在线丨porny丨国产| 337p日本欧洲亚洲大胆色噜噜| 亚洲国产精品久久一线不卡| 成人亚洲一区二区一| 欧美一区午夜视频在线观看| 亚洲区小说区图片区qvod| 国产一区在线视频| 欧美一区二区在线看| 一区二区高清视频在线观看| 成人黄色片在线观看| 久久久久国产精品人| 日日夜夜一区二区| 欧美性猛交xxxxxxxx| 亚洲欧美激情视频在线观看一区二区三区 | 99精品欧美一区| 国产午夜精品一区二区| 视频一区中文字幕| 欧美亚洲综合网| 亚洲免费av网站| 不卡的av中国片| 中文字幕欧美激情一区| 国产一区二区在线电影| 7777精品伊人久久久大香线蕉超级流畅 | 国产精品一区二区在线看| 日韩视频一区二区| 蜜桃一区二区三区在线观看| 91精品视频网| 免费观看一级特黄欧美大片| 4hu四虎永久在线影院成人| 夜夜精品浪潮av一区二区三区| 91蝌蚪porny成人天涯| 日韩美女啊v在线免费观看|