~ubuntu-branches/ubuntu/maverick/openssl/maverick

« back to all changes in this revision

Viewing changes to apps/x509.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Martin
  • Date: 2004-12-16 18:41:29 UTC
  • mto: (11.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041216184129-z7xjkul57mh1jiha
Tags: upstream-0.9.7e
ImportĀ upstreamĀ versionĀ 0.9.7e

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
        char *CAkeyfile=NULL,*CAserial=NULL;
169
169
        char *alias=NULL;
170
170
        int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;
171
 
        int ocspid=0;
 
171
        int next_serial=0,ocspid=0;
172
172
        int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0,email=0;
173
173
        int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0;
174
174
        int C=0;
371
371
                        email= ++num;
372
372
                else if (strcmp(*argv,"-serial") == 0)
373
373
                        serial= ++num;
 
374
                else if (strcmp(*argv,"-next_serial") == 0)
 
375
                        next_serial= ++num;
374
376
                else if (strcmp(*argv,"-modulus") == 0)
375
377
                        modulus= ++num;
376
378
                else if (strcmp(*argv,"-pubkey") == 0)
591
593
                if ((x=X509_new()) == NULL) goto end;
592
594
                ci=x->cert_info;
593
595
 
594
 
                if (sno)
 
596
                if (sno == NULL)
595
597
                        {
596
 
                        if (!X509_set_serialNumber(x, sno))
 
598
                        sno = ASN1_INTEGER_new();
 
599
                        if (!sno || !rand_serial(NULL, sno))
597
600
                                goto end;
598
601
                        }
599
 
                else if (!ASN1_INTEGER_set(X509_get_serialNumber(x),0)) goto end;
 
602
 
 
603
                if (!X509_set_serialNumber(x, sno)) 
 
604
                        goto end;
 
605
 
600
606
                if (!X509_set_issuer_name(x,req->req_info->subject)) goto end;
601
607
                if (!X509_set_subject_name(x,req->req_info->subject)) goto end;
602
608
 
617
623
                if (xca == NULL) goto end;
618
624
                }
619
625
 
620
 
        if (!noout || text)
 
626
        if (!noout || text || next_serial)
621
627
                {
622
628
                OBJ_create("2.99999.3",
623
629
                        "SET.ex3","SET x509v3 extension 3");
691
697
                                i2a_ASN1_INTEGER(STDout,x->cert_info->serialNumber);
692
698
                                BIO_printf(STDout,"\n");
693
699
                                }
 
700
                        else if (next_serial == i)
 
701
                                {
 
702
                                BIGNUM *bnser;
 
703
                                ASN1_INTEGER *ser;
 
704
                                ser = X509_get_serialNumber(x);
 
705
                                bnser = ASN1_INTEGER_to_BN(ser, NULL);
 
706
                                if (!bnser)
 
707
                                        goto end;
 
708
                                if (!BN_add_word(bnser, 1))
 
709
                                        goto end;
 
710
                                ser = BN_to_ASN1_INTEGER(bnser, NULL);
 
711
                                if (!ser)
 
712
                                        goto end;
 
713
                                BN_free(bnser);
 
714
                                i2a_ASN1_INTEGER(out, ser);
 
715
                                ASN1_INTEGER_free(ser);
 
716
                                BIO_puts(out, "\n");
 
717
                                }
694
718
                        else if (email == i) 
695
719
                                {
696
720
                                int j;
1047
1071
                }
1048
1072
        else
1049
1073
                BUF_strlcpy(buf,serialfile,len);
1050
 
        serial=BN_new();
1051
 
        bs=ASN1_INTEGER_new();
1052
 
        if ((serial == NULL) || (bs == NULL))
1053
 
                {
1054
 
                ERR_print_errors(bio_err);
1055
 
                goto end;
1056
 
                }
1057
1074
 
1058
1075
        serial = load_serial(buf, create, NULL);
1059
1076
        if (serial == NULL) goto end;