Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  mksp.c

  Sprache: C
 

/*
 *  mksp.c
 *
 *  Generate SP tables for DES-150 library
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include <stdio.h>

/*
 * sboxes - the tables for the s-box functions
 *        from FIPS 46, pages 15-16.
 */

unsigned char S[8][64] = {
    /* Func S1 = */
    { 14041513714214152111381,
      310106612121159950378,
      415112148821346921117,
      15512119371431010056013 },
    /* Func S2 = */
    { 1531138414761511238414,
      9127021131012609511105,
      01314871011110341513412,
      511861276129035214159 },
    /* Func S3 = */
    { 101307901496334156510,
      12138125714111241121581,
      13161041390861593807,
      114115214123511105142712 },
    /* Func S4 = */
    { 7131381411350661590103,
      1427825121111210414159,
      10361590061210111713138,
      159143514115122782414 },
    /* Func S5 = */
    { 21412114211274107111361,
      855031515101330914896,
      41128112117101131472813,
      156915120596103405143 },
    /* Func S6 = */
    { 1210115104152972126985,
      0613131341414071153118,
      9414315251229851215310,
      7110144110716130118613 },
    /* Func S7 = */
    { 41311021114715409811310,
      314123957125210156816,
      16411111313812134710147,
      109155608150145293212 },
    /* Func S8 = */
    { 1312158134861015311714,
      1012953614115001412972,
      7211141417941210148213,
      0156121091301533556811 }
};

/*
 * Permutation function for results from s-boxes
 *   from FIPS 46 pages 12 and 16.
 * P =
 */

unsigned char P[32] = {
    167202129122817,
    11523265183110,
    282414322739,
    19133062211425
};

unsigned int Pinv[32];
unsigned int SP[8][64];

void
makePinv(void)
{
    int i;
    unsigned int Pi = 0x80000000;
    for (i = 0; i < 32; ++i) {
        int j = 32 - P[i];
        Pinv[j] = Pi;
        Pi >>= 1;
    }
}

void
makeSP(void)
{
    int box;
    for (box = 0; box < 8; ++box) {
        int item;
        printf("/* box S%d */ {\n", box + 1);
        for (item = 0; item < 64; ++item) {
            unsigned int s = S[box][item];
            unsigned int val = 0;
            unsigned int bitnum = (7 - box) * 4;
            for (; s; s >>= 1, ++bitnum) {
                if (s & 1) {
                    val |= Pinv[bitnum];
                }
            }
            val = (val << 3) | (val >> 29);
            SP[box][item] = val;
        }
        for (item = 0; item < 64; item += 4) {
            printf("\t0x%08x, 0x%08x, 0x%08x, 0x%08x,\n",
                   SP[box][item], SP[box][item + 1], SP[box][item + 2], SP[box][item + 3]);
        }
        printf("    },\n");
    }
}

int
main()
{
    makePinv();
    makeSP();
    return 0;
}

Messung V0.5 in Prozent
C=92 H=88 G=89

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik