Annotation of rpl/src/instructions_c8.c, revision 1.1

1.1     ! bertrand    1: /*
        !             2: ================================================================================
        !             3:   RPL/2 (R) version 4.1.12
        !             4:   Copyright (C) 1989-2012 Dr. BERTRAND Joël
        !             5: 
        !             6:   This file is part of RPL/2.
        !             7: 
        !             8:   RPL/2 is free software; you can redistribute it and/or modify it
        !             9:   under the terms of the CeCILL V2 License as published by the french
        !            10:   CEA, CNRS and INRIA.
        !            11:  
        !            12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
        !            13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
        !            14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
        !            15:   for more details.
        !            16:  
        !            17:   You should have received a copy of the CeCILL License
        !            18:   along with RPL/2. If not, write to info@cecill.info.
        !            19: ================================================================================
        !            20: */
        !            21: 
        !            22: 
        !            23: #include "rpl-conv.h"
        !            24: 
        !            25: 
        !            26: /*
        !            27: ================================================================================
        !            28:   Fonction 'cipher'
        !            29: ================================================================================
        !            30:   Entrées :
        !            31: --------------------------------------------------------------------------------
        !            32:   Sorties :
        !            33: --------------------------------------------------------------------------------
        !            34:   Effets de bord : néant
        !            35: ================================================================================
        !            36: */
        !            37: 
        !            38: void
        !            39: instruction_cipher(struct_processus *s_etat_processus)
        !            40: {
        !            41:    const EVP_CIPHER                *EVP_chiffrement;
        !            42:    const EVP_MD                    *EVP_sum;
        !            43: 
        !            44:    integer8                        nombre_cycles;
        !            45: 
        !            46:    logical1                        somme_invalide;
        !            47:    logical1                        generation_clef;
        !            48: 
        !            49:    logical8                        sel;
        !            50: 
        !            51:    struct_liste_chainee            *l_element_courant;
        !            52: 
        !            53:    struct_objet                    *s_objet_argument_1;
        !            54:    struct_objet                    *s_objet_argument_2;
        !            55:    struct_objet                    *s_objet_resultat_1;
        !            56:    struct_objet                    *s_objet_resultat_2;
        !            57: 
        !            58:    unsigned char                   *chiffrement;
        !            59:    unsigned char                   *clef;
        !            60:    unsigned char                   *controle;
        !            61:    unsigned char                   *direction;
        !            62:    unsigned char                   *fonction;
        !            63:    unsigned char                   *instruction;
        !            64:    unsigned char                   *iv;
        !            65:    unsigned char                   *tampon;
        !            66: 
        !            67:    if ((*s_etat_processus).affichage_arguments == 'Y')
        !            68:    {
        !            69:        printf("\n  CIPHER ");
        !            70: 
        !            71:        if ((*s_etat_processus).langue == 'F')
        !            72:        {
        !            73:            printf("(opérations de chiffrement)\n\n");
        !            74:        }
        !            75:        else
        !            76:        {
        !            77:            printf("(cryptographic operations)\n\n");
        !            78:        }
        !            79: 
        !            80:        printf("    2: %s \"password\"\n", d_CHN);
        !            81:        printf("    1: %s { \"KEY\" \"cipher type\" \"digest type\" "
        !            82:                "salt nround }\n", d_LST);
        !            83:        printf("->  1: %s { \"generated key\" \"iv\" }\n\n", d_LST);
        !            84: 
        !            85:        printf("    2: %s \"text\"\n", d_CHN);
        !            86:        printf("    1: %s { \"cipher type\" \"direction\" \"key\" \"iv\" }\n",
        !            87:                d_LST);
        !            88:        printf("->  2: %s \"encrypted or decrypted text\"\n", d_CHN);
        !            89:        printf("    1: %s { \"cipher type\" \"direction\" \"key\" "
        !            90:                "\"updated iv\" }\n\n", d_LST);
        !            91: 
        !            92:        if ((*s_etat_processus).langue == 'F')
        !            93:        {
        !            94:            printf("  Algorithmes de signature :\n\n");
        !            95:        }
        !            96:        else
        !            97:        {
        !            98:            printf("  Digest algorithms:\n\n");
        !            99:        }
        !           100: 
        !           101: #      ifndef OPENSSL_NO_SHA
        !           102:        printf("    - DSS\n");
        !           103:        printf("    - DSS1\n");
        !           104:        printf("    - ECDSA\n");
        !           105: #      endif
        !           106: #      ifndef OPENSSL_NO_MD2
        !           107:        printf("    - MD2\n");
        !           108: #      endif
        !           109: #      ifndef OPENSSL_NO_MD4
        !           110:        printf("    - MD4\n");
        !           111: #      endif
        !           112: #      ifndef OPENSSL_NO_MD5
        !           113:        printf("    - MD5\n");
        !           114: #      endif
        !           115: #      ifndef OPENSSL_NO_MDC2
        !           116:        printf("    - MDC2\n");
        !           117: #      endif
        !           118: #      ifndef OPENSSL_NO_RIPEMD
        !           119:        printf("    - RIPEMD160\n");
        !           120: #      endif
        !           121: #      ifndef OPENSSL_NO_SHA
        !           122:        printf("    - SHA\n");
        !           123:        printf("    - SHA1\n");
        !           124: #      endif
        !           125: #      ifndef OPENSSL_NO_SHA256
        !           126:        printf("    - SHA224\n");
        !           127:        printf("    - SHA256\n");
        !           128: #      endif
        !           129: #      ifndef OPENSSL_NO_SHA512
        !           130:        printf("    - SHA384\n");
        !           131:        printf("    - SHA512\n");
        !           132: #      endif
        !           133: #      ifndef OPENSSL_NO_WHIRLPOOL
        !           134:        printf("    - WHIRLPOOL\n");
        !           135: #      endif
        !           136: 
        !           137:        printf("\n");
        !           138: 
        !           139:        if ((*s_etat_processus).langue == 'F')
        !           140:        {
        !           141:            printf("  Utilisation :\n\n");
        !           142:        }
        !           143:        else
        !           144:        {
        !           145:            printf("  Usage:\n\n");
        !           146:        }
        !           147: 
        !           148:        printf("    \"password\" { \"key\" \"SHA1\" # 0h 3 } CIPHER\n");
        !           149:        printf("    \"text\" { \"AES-128-CBC\" \"DECRYPT\" \"key\" "
        !           150:                "\"iv\" } CIPHER\n");
        !           151:        printf("    \"text\" { \"AES-128-EBC\" \"ENCRYPT\" \"key\" "
        !           152:                "\"iv\" } CIPHER\n");
        !           153:        return;
        !           154:    }
        !           155:    else if ((*s_etat_processus).test_instruction == 'Y')
        !           156:    {
        !           157:        (*s_etat_processus).nombre_arguments = -1;
        !           158:        return;
        !           159:    }
        !           160: 
        !           161:    if (test_cfsf(s_etat_processus, 31) == d_vrai)
        !           162:    {
        !           163:        if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
        !           164:        {
        !           165:            return;
        !           166:        }
        !           167:    }
        !           168: 
        !           169:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !           170:            &s_objet_argument_1) == d_erreur)
        !           171:    {
        !           172:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !           173:        return;
        !           174:    }
        !           175: 
        !           176:    if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
        !           177:            &s_objet_argument_2) == d_erreur)
        !           178:    {
        !           179:        liberation(s_etat_processus, s_objet_argument_1);
        !           180: 
        !           181:        (*s_etat_processus).erreur_execution = d_ex_manque_argument;
        !           182:        return;
        !           183:    }
        !           184: 
        !           185:    if (((*s_objet_argument_1).type == LST) &&
        !           186:            ((*s_objet_argument_2).type == CHN))
        !           187:    {
        !           188:        l_element_courant = (*s_objet_argument_1).objet;
        !           189: 
        !           190:        if (l_element_courant == NULL)
        !           191:        {
        !           192:            liberation(s_etat_processus, s_objet_argument_1);
        !           193:            liberation(s_etat_processus, s_objet_argument_2);
        !           194: 
        !           195:            (*s_etat_processus).erreur_execution = d_ex_argument_invalide; 
        !           196:            return;
        !           197:        }
        !           198: 
        !           199:        if ((*(*l_element_courant).donnee).type != CHN)
        !           200:        {
        !           201:            liberation(s_etat_processus, s_objet_argument_1);
        !           202:            liberation(s_etat_processus, s_objet_argument_2);
        !           203: 
        !           204:            (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !           205:            return;
        !           206:        }
        !           207: 
        !           208:        if ((instruction = conversion_majuscule((unsigned char *)
        !           209:                (*(*l_element_courant).donnee).objet)) == NULL)
        !           210:        {
        !           211:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           212:            return;
        !           213:        }
        !           214: 
        !           215:        if (strcmp(instruction, "KEY") == 0)
        !           216:        {
        !           217:            // Dérivation d'une clef
        !           218: 
        !           219:            free(instruction);
        !           220: 
        !           221:            l_element_courant = (*l_element_courant).suivant;
        !           222: 
        !           223:            if (l_element_courant == NULL)
        !           224:            {
        !           225:                liberation(s_etat_processus, s_objet_argument_1);
        !           226:                liberation(s_etat_processus, s_objet_argument_2);
        !           227: 
        !           228:                (*s_etat_processus).erreur_execution = d_ex_manque_argument; 
        !           229:                return;
        !           230:            }
        !           231: 
        !           232:            // On attend l'algorithme de chiffrement.
        !           233: 
        !           234:            if ((*(*l_element_courant).donnee).type != CHN)
        !           235:            {
        !           236:                liberation(s_etat_processus, s_objet_argument_1);
        !           237:                liberation(s_etat_processus, s_objet_argument_2);
        !           238: 
        !           239:                (*s_etat_processus).erreur_execution =
        !           240:                        d_ex_erreur_type_argument;
        !           241:                return;
        !           242:            }
        !           243: 
        !           244:            chiffrement = (unsigned char *) (*(*l_element_courant)
        !           245:                    .donnee).objet;
        !           246: 
        !           247:            if ((l_element_courant = (*l_element_courant).suivant) == NULL)
        !           248:            {
        !           249:                liberation(s_etat_processus, s_objet_argument_1);
        !           250:                liberation(s_etat_processus, s_objet_argument_2);
        !           251: 
        !           252:                (*s_etat_processus).erreur_execution = d_ex_manque_argument; 
        !           253:                return;
        !           254:            }   
        !           255: 
        !           256:            // On attend la somme de contrôle.
        !           257: 
        !           258:            if ((*(*l_element_courant).donnee).type != CHN)
        !           259:            {
        !           260:                liberation(s_etat_processus, s_objet_argument_1);
        !           261:                liberation(s_etat_processus, s_objet_argument_2);
        !           262: 
        !           263:                (*s_etat_processus).erreur_execution =
        !           264:                        d_ex_erreur_type_argument;
        !           265:                return;
        !           266:            }
        !           267: 
        !           268:            controle = (unsigned char *) (*(*l_element_courant).donnee).objet;
        !           269: 
        !           270:            if ((l_element_courant = (*l_element_courant).suivant) == NULL)
        !           271:            {
        !           272:                liberation(s_etat_processus, s_objet_argument_1);
        !           273:                liberation(s_etat_processus, s_objet_argument_2);
        !           274: 
        !           275:                (*s_etat_processus).erreur_execution = d_ex_manque_argument; 
        !           276:                return;
        !           277:            }   
        !           278: 
        !           279: 
        !           280:            // On attend le sel, donc un entier binaire de 64 bits.
        !           281: 
        !           282:            if ((*(*l_element_courant).donnee).type != BIN)
        !           283:            {
        !           284:                liberation(s_etat_processus, s_objet_argument_1);
        !           285:                liberation(s_etat_processus, s_objet_argument_2);
        !           286: 
        !           287:                (*s_etat_processus).erreur_execution =
        !           288:                        d_ex_erreur_type_argument;
        !           289:                return;
        !           290:            }
        !           291: 
        !           292:            sel = (*((logical8 *) (*(*l_element_courant).donnee).objet));
        !           293: 
        !           294:            if ((l_element_courant = (*l_element_courant).suivant) == NULL)
        !           295:            {
        !           296:                liberation(s_etat_processus, s_objet_argument_1);
        !           297:                liberation(s_etat_processus, s_objet_argument_2);
        !           298: 
        !           299:                (*s_etat_processus).erreur_execution = d_ex_manque_argument; 
        !           300:                return;
        !           301:            }   
        !           302: 
        !           303:            // On attend le nombre de cycles.
        !           304: 
        !           305:            if ((*(*l_element_courant).donnee).type != INT)
        !           306:            {
        !           307:                liberation(s_etat_processus, s_objet_argument_1);
        !           308:                liberation(s_etat_processus, s_objet_argument_2);
        !           309: 
        !           310:                (*s_etat_processus).erreur_execution =
        !           311:                        d_ex_erreur_type_argument;
        !           312:                return;
        !           313:            }
        !           314: 
        !           315:            nombre_cycles = (*((integer8 *) (*(*l_element_courant)
        !           316:                    .donnee).objet));
        !           317: 
        !           318:            // On a dû atteindre la fin de la liste.
        !           319: 
        !           320:            if ((*l_element_courant).suivant != NULL)
        !           321:            {
        !           322:                liberation(s_etat_processus, s_objet_argument_1);
        !           323:                liberation(s_etat_processus, s_objet_argument_2);
        !           324: 
        !           325:                (*s_etat_processus).erreur_execution = d_ex_argument_invalide; 
        !           326:                return;
        !           327:            }
        !           328: 
        !           329:            // Test de la validité de la somme de contrôle.
        !           330: 
        !           331:            if ((fonction = conversion_majuscule(controle)) == NULL)
        !           332:            {
        !           333:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           334:                return;
        !           335:            }
        !           336: 
        !           337:            somme_invalide = d_faux;
        !           338: 
        !           339:            switch(fonction[0])
        !           340:            {
        !           341:                case 'D':
        !           342:                {
        !           343:                    switch(fonction[1])
        !           344:                    {
        !           345:                        case 'S': // ds
        !           346:                        {
        !           347:                            switch(fonction[2])
        !           348:                            {
        !           349: #                              ifndef OPENSSL_NO_SHA
        !           350:                                case 'S': // dss
        !           351:                                {
        !           352:                                    switch(fonction[3])
        !           353:                                    {
        !           354:                                        case d_code_fin_chaine:
        !           355:                                        {
        !           356:                                            EVP_sum = EVP_dss();
        !           357:                                            break;
        !           358:                                        }
        !           359: 
        !           360:                                        case '1': // dss1
        !           361:                                        {
        !           362:                                            if (fonction[4] ==
        !           363:                                                    d_code_fin_chaine)
        !           364:                                            {
        !           365:                                                EVP_sum = EVP_dss1();
        !           366:                                            }
        !           367:                                            else
        !           368:                                            {
        !           369:                                                somme_invalide = d_vrai;
        !           370:                                            }
        !           371: 
        !           372:                                            break;
        !           373:                                        }
        !           374: 
        !           375:                                        default:
        !           376:                                        {
        !           377:                                            somme_invalide = d_vrai;
        !           378:                                            break;
        !           379:                                        }
        !           380:                                    }
        !           381: 
        !           382:                                    break;
        !           383:                                }
        !           384: #                              endif
        !           385: 
        !           386:                                default:
        !           387:                                {
        !           388:                                    somme_invalide = d_vrai;
        !           389:                                    break;
        !           390:                                }
        !           391:                            }
        !           392: 
        !           393:                            break;
        !           394:                        }
        !           395: 
        !           396:                        default:
        !           397:                        {
        !           398:                            somme_invalide = d_vrai;
        !           399:                            break;
        !           400:                        }
        !           401:                    }
        !           402: 
        !           403:                    break;
        !           404:                }
        !           405: 
        !           406:                case 'E':
        !           407:                {
        !           408:                    switch(fonction[1])
        !           409:                    {
        !           410:                        case 'C': // ec
        !           411:                        {
        !           412:                            switch(fonction[2])
        !           413:                            {
        !           414:                                case 'D': // ecd
        !           415:                                {
        !           416:                                    switch(fonction[3])
        !           417:                                    {
        !           418:                                        case 'S': // ecds
        !           419:                                        {
        !           420:                                            switch(fonction[4])
        !           421:                                            {
        !           422: #                                              ifndef OPENSSL_NO_SHA
        !           423:                                                case 'A': // ecdsa
        !           424:                                                {
        !           425:                                                    if (fonction[5] ==
        !           426:                                                            d_code_fin_chaine)
        !           427:                                                    {
        !           428:                                                        EVP_sum = EVP_ecdsa();
        !           429:                                                    }
        !           430:                                                    else
        !           431:                                                    {
        !           432:                                                        somme_invalide = d_vrai;
        !           433:                                                    }
        !           434: 
        !           435:                                                    break;
        !           436:                                                }
        !           437: #                                              endif
        !           438: 
        !           439:                                                default:
        !           440:                                                {
        !           441:                                                    somme_invalide = d_vrai;
        !           442:                                                    break;
        !           443:                                                }
        !           444:                                            }
        !           445: 
        !           446:                                            break;
        !           447:                                        }
        !           448: 
        !           449:                                        default:
        !           450:                                        {
        !           451:                                            somme_invalide = d_vrai;
        !           452:                                            break;
        !           453:                                        }
        !           454:                                    }
        !           455: 
        !           456:                                    break;
        !           457:                                }
        !           458: 
        !           459:                                default:
        !           460:                                {
        !           461:                                    somme_invalide = d_vrai;
        !           462:                                    break;
        !           463:                                }
        !           464:                            }
        !           465: 
        !           466:                            break;
        !           467:                        }
        !           468: 
        !           469:                        default:
        !           470:                        {
        !           471:                            somme_invalide = d_vrai;
        !           472:                            break;
        !           473:                        }
        !           474:                    }
        !           475: 
        !           476:                    break;
        !           477:                }
        !           478: 
        !           479:                case 'M':
        !           480:                {
        !           481:                    switch(fonction[1])
        !           482:                    {
        !           483:                        case 'D': // md
        !           484:                        {
        !           485:                            switch(fonction[2])
        !           486:                            {
        !           487: #                              ifndef OPENSSL_NO_MD2
        !           488:                                case '2': // md2
        !           489:                                {
        !           490:                                    if (fonction[3] == d_code_fin_chaine)
        !           491:                                    {
        !           492:                                        EVP_sum = EVP_md2();
        !           493:                                    }
        !           494:                                    else
        !           495:                                    {
        !           496:                                        somme_invalide = d_vrai;
        !           497:                                    }
        !           498: 
        !           499:                                    break;
        !           500:                                }
        !           501: #                              endif
        !           502: 
        !           503: #                              ifndef OPENSSL_NO_MD4
        !           504:                                case '4': // md4
        !           505:                                {
        !           506:                                    if (fonction[3] == d_code_fin_chaine)
        !           507:                                    {
        !           508:                                        EVP_sum = EVP_md4();
        !           509:                                    }
        !           510:                                    else
        !           511:                                    {
        !           512:                                        somme_invalide = d_vrai;
        !           513:                                    }
        !           514: 
        !           515:                                    break;
        !           516:                                }
        !           517: #                              endif
        !           518: 
        !           519: #                              ifndef OPENSSL_NO_MD5
        !           520:                                case '5': // md5
        !           521:                                {
        !           522:                                    if (fonction[3] == d_code_fin_chaine)
        !           523:                                    {
        !           524:                                        EVP_sum = EVP_md5();
        !           525:                                    }
        !           526:                                    else
        !           527:                                    {
        !           528:                                        somme_invalide = d_vrai;
        !           529:                                    }
        !           530: 
        !           531:                                    break;
        !           532:                                }
        !           533: #                              endif
        !           534: 
        !           535:                                case 'C': // mdc
        !           536:                                {
        !           537:                                    switch(fonction[3])
        !           538:                                    {
        !           539: #                                      ifndef OPENSSL_NO_MDC2
        !           540:                                        case '2': // mdc2
        !           541:                                        {
        !           542:                                            if (fonction[4] ==
        !           543:                                                    d_code_fin_chaine)
        !           544:                                            {
        !           545:                                                EVP_sum = EVP_mdc2();
        !           546:                                            }
        !           547:                                            else
        !           548:                                            {
        !           549:                                                somme_invalide = d_vrai;
        !           550:                                            }
        !           551: 
        !           552:                                            break;
        !           553:                                        }
        !           554: #                                      endif
        !           555: 
        !           556:                                        default:
        !           557:                                        {
        !           558:                                            somme_invalide = d_vrai;
        !           559:                                            break;
        !           560:                                        }
        !           561:                                    }
        !           562: 
        !           563:                                    break;
        !           564:                                }
        !           565: 
        !           566:                                default:
        !           567:                                {
        !           568:                                    somme_invalide = d_vrai;
        !           569:                                    break;
        !           570:                                }
        !           571:                            }
        !           572: 
        !           573:                            break;
        !           574:                        }
        !           575: 
        !           576:                        default:
        !           577:                        {
        !           578:                            somme_invalide = d_vrai;
        !           579:                            break;
        !           580:                        }
        !           581:                    }
        !           582: 
        !           583:                    break;
        !           584:                }
        !           585: 
        !           586: #              ifndef OPENSSL_NO_RIPEMD
        !           587:                case 'R':
        !           588:                {
        !           589:                    if (strcmp(fonction, "RIPEMD160") == 0)
        !           590:                    {
        !           591:                        EVP_sum = EVP_ripemd160();
        !           592:                    }
        !           593:                    else
        !           594:                    {
        !           595:                        somme_invalide = d_vrai;
        !           596:                    }
        !           597: 
        !           598:                    break;
        !           599:                }
        !           600: #              endif
        !           601: 
        !           602:                case 'S':
        !           603:                {
        !           604:                    switch(fonction[1])
        !           605:                    {
        !           606:                        case 'H': // sh
        !           607:                        {
        !           608:                            switch(fonction[2])
        !           609:                            {
        !           610: #                              ifndef OPENSSL_NO_SHA
        !           611:                                case 'A':
        !           612:                                {
        !           613:                                    switch(fonction[3])
        !           614:                                    {
        !           615:                                        case d_code_fin_chaine:
        !           616:                                        {
        !           617:                                            EVP_sum = EVP_sha();
        !           618:                                            break;
        !           619:                                        }
        !           620: 
        !           621:                                        case '1': // sha1
        !           622:                                        {
        !           623:                                            if (fonction[4] ==
        !           624:                                                    d_code_fin_chaine)
        !           625:                                            {
        !           626:                                                EVP_sum = EVP_sha1();
        !           627:                                            }
        !           628:                                            else
        !           629:                                            {
        !           630:                                                somme_invalide = d_vrai;
        !           631:                                            }
        !           632: 
        !           633:                                            break;
        !           634:                                        }
        !           635: 
        !           636: #                                      ifndef OPENSSL_NO_SHA256
        !           637:                                        case '2': // sha2
        !           638:                                        {
        !           639:                                            switch(fonction[4])
        !           640:                                            {
        !           641:                                                case '2': // sha22
        !           642:                                                {
        !           643:                                                    switch(fonction[5])
        !           644:                                                    {
        !           645:                                                        case '4': // sha224
        !           646:                                                        {
        !           647:                                                            if (fonction[6] ==
        !           648:                                                            d_code_fin_chaine)
        !           649:                                                            {
        !           650:                                                                EVP_sum =
        !           651:                                                                EVP_sha224();
        !           652:                                                            }
        !           653:                                                            else
        !           654:                                                            {
        !           655:                                                                somme_invalide =
        !           656:                                                                        d_vrai;
        !           657:                                                            }
        !           658: 
        !           659:                                                            break;
        !           660:                                                        }
        !           661: 
        !           662:                                                        default:
        !           663:                                                        {
        !           664:                                                            somme_invalide =
        !           665:                                                                    d_vrai;
        !           666:                                                            break;
        !           667:                                                        }
        !           668:                                                    }
        !           669: 
        !           670:                                                    break;
        !           671:                                                }
        !           672: 
        !           673:                                                case '5':
        !           674:                                                {
        !           675:                                                    switch(fonction[5])
        !           676:                                                    {
        !           677:                                                        case '6': // sha256
        !           678:                                                        {
        !           679:                                                            if (fonction[6] ==
        !           680:                                                            d_code_fin_chaine)
        !           681:                                                            {
        !           682:                                                                EVP_sum =
        !           683:                                                                EVP_sha256();
        !           684:                                                            }
        !           685:                                                            else
        !           686:                                                            {
        !           687:                                                                somme_invalide =
        !           688:                                                                        d_vrai;
        !           689:                                                            }
        !           690: 
        !           691:                                                            break;
        !           692:                                                        }
        !           693: 
        !           694:                                                        default:
        !           695:                                                        {
        !           696:                                                            somme_invalide =
        !           697:                                                                    d_vrai;
        !           698:                                                            break;
        !           699:                                                        }
        !           700:                                                    }
        !           701: 
        !           702:                                                    break;
        !           703:                                                }
        !           704: 
        !           705:                                                default:
        !           706:                                                {
        !           707:                                                    somme_invalide = d_vrai;
        !           708:                                                    break;
        !           709:                                                }
        !           710:                                            }
        !           711: 
        !           712:                                            break;
        !           713:                                        }
        !           714: #                                      endif
        !           715: 
        !           716: #                                      ifndef OPENSSL_NO_SHA512
        !           717:                                        case '3': // sha3
        !           718:                                        {
        !           719:                                            switch(fonction[4])
        !           720:                                            {
        !           721:                                                case '8': // sha38
        !           722:                                                {
        !           723:                                                    switch(fonction[5])
        !           724:                                                    {
        !           725:                                                        case '4': // sha384
        !           726:                                                        {
        !           727:                                                            if (fonction[6] ==
        !           728:                                                            d_code_fin_chaine)
        !           729:                                                            {
        !           730:                                                                EVP_sum =
        !           731:                                                                EVP_sha384();
        !           732:                                                            }
        !           733:                                                            else
        !           734:                                                            {
        !           735:                                                                somme_invalide =
        !           736:                                                                        d_vrai;
        !           737:                                                            }
        !           738: 
        !           739:                                                            break;
        !           740:                                                        }
        !           741: 
        !           742:                                                        default:
        !           743:                                                        {
        !           744:                                                            somme_invalide =
        !           745:                                                                    d_vrai;
        !           746:                                                            break;
        !           747:                                                        }
        !           748:                                                    }
        !           749: 
        !           750:                                                    break;
        !           751:                                                }
        !           752: 
        !           753:                                                default:
        !           754:                                                {
        !           755:                                                    somme_invalide = d_vrai;
        !           756:                                                    break;
        !           757:                                                }
        !           758:                                            }
        !           759: 
        !           760:                                            break;
        !           761:                                        }
        !           762: 
        !           763:                                        case '5': // sha5
        !           764:                                        {
        !           765:                                            switch(fonction[4])
        !           766:                                            {
        !           767:                                                case '1': // sha51
        !           768:                                                {
        !           769:                                                    switch(fonction[5])
        !           770:                                                    {
        !           771:                                                        case '2': // sha512
        !           772:                                                        {
        !           773:                                                            if (fonction[6] ==
        !           774:                                                            d_code_fin_chaine)
        !           775:                                                            {
        !           776:                                                                EVP_sum =
        !           777:                                                                EVP_sha512();
        !           778:                                                            }
        !           779:                                                            else
        !           780:                                                            {
        !           781:                                                                somme_invalide =
        !           782:                                                                        d_vrai;
        !           783:                                                            }
        !           784: 
        !           785:                                                            break;
        !           786:                                                        }
        !           787: 
        !           788:                                                        default:
        !           789:                                                        {
        !           790:                                                            somme_invalide =
        !           791:                                                                    d_vrai;
        !           792:                                                            break;
        !           793:                                                        }
        !           794:                                                    }
        !           795: 
        !           796:                                                    break;
        !           797:                                                }
        !           798: 
        !           799:                                                default:
        !           800:                                                {
        !           801:                                                    somme_invalide = d_vrai;
        !           802:                                                    break;
        !           803:                                                }
        !           804:                                            }
        !           805: 
        !           806:                                            break;
        !           807:                                        }
        !           808: #                                      endif
        !           809: 
        !           810:                                        default:
        !           811:                                        {
        !           812:                                            somme_invalide = d_vrai;
        !           813:                                            break;
        !           814:                                        }
        !           815:                                    }
        !           816: 
        !           817:                                    break;
        !           818:                                }
        !           819: #                              endif
        !           820: 
        !           821:                                default:
        !           822:                                {
        !           823:                                    somme_invalide = d_vrai;
        !           824:                                    break;
        !           825:                                }
        !           826:                            }
        !           827: 
        !           828:                            break;
        !           829:                        }
        !           830: 
        !           831:                        default:
        !           832:                        {
        !           833:                            somme_invalide = d_vrai;
        !           834:                            break;
        !           835:                        }
        !           836:                    }
        !           837: 
        !           838:                    break;
        !           839:                }
        !           840: 
        !           841: #              ifndef OPENSSL_NO_WHIRLPOOL
        !           842:                case 'W':
        !           843:                {
        !           844:                    if (strcmp(fonction, "WHIRLPOOL") == 0)
        !           845:                    {
        !           846:                        EVP_sum = EVP_whirlpool();
        !           847:                    }
        !           848:                    else
        !           849:                    {
        !           850:                        somme_invalide = d_vrai;
        !           851:                    }
        !           852: 
        !           853:                    break;
        !           854:                }
        !           855: #              endif
        !           856: 
        !           857:                default:
        !           858:                {
        !           859:                    somme_invalide = d_vrai;
        !           860:                    break;
        !           861:                }
        !           862:            }
        !           863: 
        !           864:            free(fonction);
        !           865: 
        !           866:            if (somme_invalide == d_vrai)
        !           867:            {
        !           868:                liberation(s_etat_processus, s_objet_argument_1);
        !           869:                liberation(s_etat_processus, s_objet_argument_2);
        !           870: 
        !           871:                (*s_etat_processus).erreur_execution =
        !           872:                        d_ex_chiffrement_indisponible;
        !           873:                return;
        !           874:            }
        !           875: 
        !           876:            generation_clef = d_vrai;
        !           877:        }
        !           878:        else
        !           879:        {
        !           880:            // Chiffrement ou déchiffrement d'un message
        !           881: 
        !           882:            chiffrement = fonction;
        !           883: 
        !           884:            l_element_courant = (*l_element_courant).suivant;
        !           885: 
        !           886:            if (l_element_courant == NULL)
        !           887:            {
        !           888:                liberation(s_etat_processus, s_objet_argument_1);
        !           889:                liberation(s_etat_processus, s_objet_argument_2);
        !           890: 
        !           891:                (*s_etat_processus).erreur_execution = d_ex_manque_argument; 
        !           892:                return;
        !           893:            }
        !           894: 
        !           895:            // On attend la direction.
        !           896: 
        !           897:            if ((*(*l_element_courant).donnee).type != CHN)
        !           898:            {
        !           899:                liberation(s_etat_processus, s_objet_argument_1);
        !           900:                liberation(s_etat_processus, s_objet_argument_2);
        !           901: 
        !           902:                (*s_etat_processus).erreur_execution =
        !           903:                        d_ex_erreur_type_argument;
        !           904:                return;
        !           905:            }
        !           906: 
        !           907:            direction = (unsigned char *) (*(*l_element_courant)
        !           908:                    .donnee).objet;
        !           909: 
        !           910:            // On attend la clef.
        !           911: 
        !           912:            if ((l_element_courant = (*l_element_courant).suivant) == NULL)
        !           913:            {
        !           914:                liberation(s_etat_processus, s_objet_argument_1);
        !           915:                liberation(s_etat_processus, s_objet_argument_2);
        !           916: 
        !           917:                (*s_etat_processus).erreur_execution =
        !           918:                        d_ex_manque_argument;
        !           919:                return;
        !           920:            }
        !           921: 
        !           922:            clef = (unsigned char *) (*(*l_element_courant).donnee).objet;
        !           923: 
        !           924:            // On attend le vecteur d'initialisation.
        !           925: 
        !           926:            if ((l_element_courant = (*l_element_courant).suivant) == NULL)
        !           927:            {
        !           928:                liberation(s_etat_processus, s_objet_argument_1);
        !           929:                liberation(s_etat_processus, s_objet_argument_2);
        !           930: 
        !           931:                (*s_etat_processus).erreur_execution =
        !           932:                        d_ex_manque_argument;
        !           933:                return;
        !           934:            }
        !           935: 
        !           936:            iv = (unsigned char *) (*(*l_element_courant).donnee).objet;
        !           937: 
        !           938:            if ((*l_element_courant).suivant != NULL)
        !           939:            {
        !           940:                liberation(s_etat_processus, s_objet_argument_1);
        !           941:                liberation(s_etat_processus, s_objet_argument_2);
        !           942: 
        !           943:                (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
        !           944:                return;
        !           945:            }
        !           946:        }
        !           947:    }
        !           948:    else
        !           949:    {
        !           950:        liberation(s_etat_processus, s_objet_argument_1);
        !           951:        liberation(s_etat_processus, s_objet_argument_2);
        !           952: 
        !           953:        (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
        !           954:        return;
        !           955:    }
        !           956: 
        !           957:    if ((tampon = conversion_majuscule(chiffrement)) == NULL)
        !           958:    {
        !           959:        (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           960:        return;
        !           961:    }
        !           962: 
        !           963:    if (strncmp(tampon, "AES", 3) == 0)
        !           964:    {
        !           965:    }
        !           966: 
        !           967:    free(tampon);
        !           968: 
        !           969:    if (generation_clef == d_vrai)
        !           970:    {
        !           971:    }
        !           972:    else
        !           973:    {
        !           974:    }
        !           975: 
        !           976:    liberation(s_etat_processus, s_objet_argument_1);
        !           977:    liberation(s_etat_processus, s_objet_argument_2);
        !           978:    return;
        !           979: }
        !           980: 
        !           981: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>