`
`55
`
`56
`
`57
`58
`
`59
`60
`61
`
`62
`63
`
`64
`
`65
`
`66
`
`67
`68
`
`69
`70
`71
`
`72
`
`73
`74
`
`75
`
`76
`77
`
`78
`
`79
`
`80
`81
`
`82
`
`83
`
`84
`
`85
`
`86
`
`87
`88
`
`89
`90
`
`91
`92
`
`93
`
`94
`
`95
`
`96
`
`97
`98
`
`99
`100
`
`101
`lO2
`
`103
`lO4
`
`105
`
`106
`
`107
`
`108
`
`* FOR ANY DIRECT,
`
`INDIRECT,
`
`INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
`
`* DAMAGES
`
`(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
`
`* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
`* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
`
`* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
`* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
`* SUCH DAMAGE.
`
`*/
`
`#ifndef lint
`
`char copyright1[]
`
`=
`
`"@(#) Copyright
`
`(c) 1980 Regents of the University of California.\n\
`
`All rights reserved.\n";
`char copyright2[]
`=
`
`(c) 1995 AT&T\nA11 rights reserved.\n";
`"@(#) Copyright
`#endif /* not lint */
`
`#include <sys/types.h>
`
`#include <sys/stat.h>
`#include <termios.h>
`
`#ifndef SUN
`
`#include <sys/ioct1.h>
`#endif
`
`#include <sys/time.h>
`
`#include <sys/fi1e.h>
`
`#include <sys/signa1.h>
`#include <unistd.h>
`
`#include <stdio.h>
`
`#ifdef SOLARIS2X
`
`#include <fcnt1.h>
`
`#endif
`
`#ifdef PTMX
`
`#include <stropts.h>
`#endif
`
`#include "global.h"
`#include "rsaref.h"
`
`#include "esm.h"
`
`char
`
`*shell;
`
`int master;
`
`int slave;
`
`int subchild;
`
`int escape=036;
`int ciphstate=0;
`
`int ciphbyte=0;
`
`/* “ */
`
`int keyed=0;
`
`struct
`
`termios tt;
`
`struct winsize win;
`
`int lb;
`
`int l;
`
`'2'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 151
`
`
`
`C:\cfs-1.3.3\esm.c
`
`109
`
`110
`111
`
`112
`
`113
`114
`
`115
`
`116
`117
`
`118
`
`119
`
`120
`121
`
`122
`
`123
`124
`
`125
`
`126
`127
`
`128
`
`129
`
`130
`
`131
`
`132
`
`133
`
`134
`
`135
`
`136
`
`137
`
`138
`
`139
`
`140
`141
`
`142
`
`143
`144
`
`145
`
`146
`147
`
`148
`
`149
`
`150
`
`151
`
`152
`
`153
`
`154
`
`155
`
`156
`
`157
`
`158
`
`159
`
`160
`
`161
`
`162
`
`#ifdef PTMX
`char
`
`*s1ave_name;
`
`#e1se
`char
`
`#endif
`
`1ine[]
`
`=
`
`"/dev/ptyXX";
`
`int aflg;
`
`#define REMOTE 0
`LOCAL 1
`
`#define
`
`#define
`
`CALC 2
`
`int mode=LOCAL;
`
`int paranoid=O;
`
`#define
`
`#define
`
`#define
`
`#define
`
`#define
`
`#define
`
`#define
`
`SL_START 0
`
`SL_GOTl
`
`SL_GOT2
`
`SL_GOT3
`
`LAN}-'
`
`SL_GOT4 4
`
`SL_KEYING 5
`
`SL_CRYPT 6
`
`int s1outstate=SL_START;
`char *cmd=NULL;
`
`FILE *fpmaster;
`
`#define bwrite(fp,buf,1en)
`
`(fwrite(buf,1en,l,fp))
`
`argv)
`main(argc,
`int
`argc;
`
`char *argv[];
`
`extern char *optarg;
`
`extern int optind;
`int Ch;
`Void finish();
`
`char *getenv();
`
`fd_set fds;
`
`while ((ch =
`
`getopt(argc,
`
`argv, "e:sp1rci"))
`
`!= EOF)
`
`switch((char)ch)
`case 'e':
`
`{
`
`cmd=optarg;
`break;
`case 'i':
`case 's':
`
`case 'p':
`
`paranoid=l;
`case 'r':
`
`mode=REMOTE;
`
`break;
`case '1':
`
`mode=LOCAL;
`
`break;
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 152
`
`
`
`C:\cfs-1.3.3\esm.c
`
`163
`
`164
`
`165
`166
`
`167
`
`168
`
`169
`170
`
`171
`172
`
`173
`174
`
`175
`176
`177
`
`178
`179
`
`180
`181
`
`182
`183
`184
`
`185
`186
`
`187
`
`188
`189
`
`190
`
`191
`192
`
`193
`
`194
`195
`
`196
`
`197
`198
`
`199
`200
`201
`
`202
`203
`
`204
`
`205
`
`206
`207
`
`208
`
`209
`210
`
`211
`212
`
`213
`
`214
`
`215
`
`216
`
`case 'c':
`
`mode=CALC;
`
`break;
`case '?':
`
`default:
`
`fprintf(stderr,
`
`"usage: esm [—r1c]
`exit(1);
`
`[—e program\n");
`
`}
`argc -= optind;
`
`argv += optind;
`
`if ((shel1=getenV("SHELL")) == NULL)
`shell = "/bin/sh";
`
`getmaster();
`
`(Void) signal(SIGCHLD, finish);
`subchild = fork();
`
`{
`if (subchild < 0)
`perror("fork");
`fai1();
`
`}
`if (subchild==O)
`
`doshell(mode);
`
`else {
`/* main loop */
`
`printf("ESM v1.0.2 — encrypted session manager\n");
`
`printf("
`randinit();
`
`by Matt Blaze, AT&T Bell Labs, December 1995\n");
`
`cipherinit();
`
`{
`switch (mode)
`case REMOTE:
`
`if (paranoid)
`
`printf("remote server ready\n");
`
`else
`
`printf("remote server ready; ctl—“ to escape\n");
`break;
`case LOCAL:
`
`printf("local layer ready (run 'esm -s' on remote)\n");
`break;
`
`default:
`
`/* not yet */
`
`printf("esm ready\n");
`
`}
`rawtty();
`
`fpmaster=fdopen(master,"w");
`
`if (fpmaster == NULL)
`done();
`
`if (paranoid)
`startsession();
`
`FD_ZERO(&fdS);
`
`FD_SET(0,&fdS);
`
`FD_SET(master,&fds);
`
`while (select
`
`(FD_SETSIZE,&fds,NULL,NULL,NULL)>0)
`
`{
`
`'4'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 153
`
`
`
`C:\cfs-1.3.3\esm.c
`
`217
`218
`
`219
`220
`
`221
`
`222
`
`223
`
`224
`225
`
`226
`
`227
`228
`
`229
`
`230
`
`231
`
`232
`233
`
`234
`
`235
`
`236
`
`237
`
`238
`
`239
`240
`
`241
`
`242
`243
`
`244
`
`245
`246
`
`247
`
`248
`249
`
`250
`
`251
`252
`
`253
`
`254
`
`255
`256
`
`257
`
`258
`
`259
`260
`
`261
`
`262
`263
`
`264
`265
`266
`
`267
`268
`
`269
`270
`
`if (FD_IssET(0,&fds))
`doinput();
`
`if (FD_ISSET(master,&fds))
`dooutput();
`
`FD_ZERO(&fds) ;
`
`FD_SET (0,&fds) ;
`
`FD_SET(master,&fds);
`
`}
`done();
`
`}
`
`}
`
`#define TRANS O
`
`#define CMDWAIT l
`
`#define CIPHER 2
`
`#define KEYWAIT 3
`
`#define IVO
`
`#define IV1
`
`#define IV2
`
`#define IV3
`
`#define CO
`
`#define C1
`
`U'|r-l>UJ[\J}-‘O
`
`int state=TRANS;
`
`int cstate=IVO;
`
`doinput()
`
`{
`
`int cc;
`
`int i;
`
`static unsigned char ibuf[5l2];
`
`if ((cc = read(O.
`
`ibuf, 512))
`
`> 0)
`
`{
`
`{
`switch (mode)
`case REMOTE:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`domasterin(ibuf[i]);
`
`break;
`case LOCAL:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`dos1avein(ibuf[i]);
`
`break;
`default:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`bwrite(fpmaster,&ibuf[i],1);
`break;
`
`}
`ff1ush(fpmaster);
`ff1ush(stdout);
`
`} else
`done();
`
`}
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 154
`
`
`
`C:\cfs-1.3.3\esm.c
`
`271
`
`272
`
`273
`274
`
`275
`276
`
`277
`278
`
`279
`280
`
`281
`
`282
`283
`284
`
`285
`
`286
`287
`
`288
`289
`290
`
`291
`
`292
`293
`294
`
`295
`296
`
`297
`
`298
`299
`
`300
`
`301
`302
`
`303
`
`304
`305
`
`306
`
`307
`308
`
`309
`310
`
`311
`
`312
`313
`314
`315
`
`316
`317
`
`318
`
`319
`320
`321
`
`322
`323
`324
`
`dos1avein(ibuf)
`
`unsigned char ibuf;
`
`{
`
`int C;
`
`static int count=0;
`
`switch (sloutstate) {
`case SL_CRYPT:
`
`{
`if (ibuf==escape)
`bwrite(stdout,">>",2);
`
`ff1ush(stdout);
`
`{
`if (s1escape())
`printf("q\r\nEntering CLEARTEXT mode\r\n");
`bwrite(fpmaster."PPPPPPPPPPPPPPPP",16);
`
`s1outstate=SL_START;
`
`}
`break;
`
`}
`c=cfb8_encrypt(ibuf);
`if (!(++count % 8))
`
`bwrite(fpmaster,"!",1);
`
`sendhex(fpmaster,c);
`break;
`default:
`
`bwrite(fpmaster,&ibuf,1);
`break;
`
`}
`
`}
`
`s1escape()
`
`{
`
`char buf;
`
`int C;
`
`int escaped=O;
`
`while (read(0,&buf,1)>0)
`
`{
`
`{
`if (escaped)
`escaped=O;
`
`bwrite(fpmaster,&buf,1);
`continue;
`
`}
`
`{
`if (buf==escape)
`c=cfb8_encrypt(buf);
`sendhex(fpmaster,c);
`return 0;
`
`}
`bwrite(stdout,&buf,1);
`
`ff1ush(stdout);
`
`if (buf=='\\') {
`escaped=1;
`continue;
`
`}
`if (buf=='\r')
`return 0;
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 155
`
`
`
`C:\cfs-1.3.3\esm.c
`
`325
`326
`
`327
`328
`
`329
`
`330
`
`331
`
`332
`
`333
`334
`
`335
`336
`
`337
`
`338
`
`339
`
`340
`
`341
`342
`
`343
`
`344
`345
`
`346
`347
`
`348
`
`349
`
`350
`351
`
`352
`353
`
`354
`355
`356
`
`357
`358
`359
`
`360
`361
`
`362
`
`363
`364
`
`365
`366
`
`367
`
`368
`
`369
`
`370
`
`371
`
`372
`373
`
`374
`
`375
`
`376
`
`377
`378
`
`if (buf=='C')
`return 1;
`
`{
`
`}
`printf("\r\nType one of the fo11owing:\r\n");
`
`printf("
`
`\\[char] to send char as c1eartext\r\n");
`
`printf("
`
`ctr1—‘ to send escape character\r\n");
`
`printf("
`
`'C'
`
`to return to CLEARTEXT session\r\n");
`
`printf(" <enter> to return to encrypted session\r\n");
`
`}
`return 1;
`
`}
`
`/* should never happen */
`
`domasterin(ibuf)
`
`unsigned char ibuf;
`
`{
`
`int c;
`
`char ch;
`
`static int bad=O;
`
`switch (state) {
`case TRANS:
`
`if (ibuf != escape)
`
`bwrite(fpmaster, &ibuf, 1);
`
`else {
`state=CMDWAIT;
`
`bwrite(stdout,">>",2);
`cstate=IVO;
`
`}
`break;
`case CMDWAIT:
`
`{
`if (ibuf == escape)
`bwrite(fpmaster, &ibuf, 1);
`state=TRANS;
`
`} else switch (ibuf)
`case '\r':
`
`{
`
`case '\n':
`
`bwrite(stdout,"\r\n",2);
`state=TRANS;
`
`break;
`case 's':
`
`case ‘S’:
`
`startsession(LONG);
`
`break;
`
`case ‘Q’:
`
`done();
`
`break;
`default:
`
`printf("Type 's'
`
`to start encrypted session\r\n");
`
`printf("
`
`printf("
`
`printf("
`break;
`
`'Q'
`
`to terminate remote session\r\n");
`
`ctr1—‘ to send escape character\r\n");
`
`<enter> to return to session\r\n");
`
`'7'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 156
`
`
`
`C:\cfs-1.3.3\esm.c
`
`379
`380
`381
`
`382
`383
`
`384
`385
`
`386
`
`387
`
`388
`389
`390
`
`391
`392
`393
`
`394
`395
`396
`397
`
`398
`399
`
`400
`401
`402
`
`403
`404
`405
`
`406
`407
`
`408
`
`409
`410
`
`411
`
`412
`
`413
`
`414
`415
`
`416
`
`417
`
`418
`419
`420
`421
`
`422
`
`423
`424
`425
`
`426
`
`427
`428
`
`429
`
`430
`431
`
`432
`
`}
`break;
`case CIPHER:
`
`if (strChr("O123456789abCdef!",ibuf)!=NULL)
`bad=O;
`
`{
`
`if ((c = cipherout(ibuf)) >= 0)
`ch=c;
`
`{
`
`bwrite(fpmaster,&ch,1);
`
`}
`
`} else if (bad++ > 16)
`de1key();
`bwrite(stdout,"XXXXXXXXXXXXXXXX",16);
`
`{
`
`if (paranoid)
`done();
`state=TRANS;
`
`} else
`ciphstate=0;
`break;
`case KEYWAIT:
`
`if (strchr("0123456789abcdef:",ibuf)!=NULL)
`masterkeyin(ibuf);
`
`{
`
`} else {
`de1key();
`bwrite(stdout,"XXXXXXXXXXXXXXXX",16);
`
`if (paranoid)
`done();
`state=TRANS;
`
`}
`break;
`
`}
`
`}
`
`int pubstat=0;
`
`int pubpos=0;
`
`unsigned char pubbyte=O;
`
`int pksize = -1;
`
`startsession()
`
`{
`
`=
`static unsigned char buf[5]
`static unsigned char co1on=':';
`int i;
`
`pk1en=dhparams[LONG].primeLen;
`
`0177,
`
`'~', 0177,
`
`'~',
`
`'L'};
`
`printf("Starting remote side of %d bit key exchange.\r\n",pk1en*8);
`printf("
`(type any character to abort)");
`ff1ush(stdout);
`
`bwrite(stdout,buf,5);
`
`if (createdh(LONG)
`return -1;
`
`< 0)
`
`for (i=0;
`
`i<pk1en;
`
`i++)
`
`sendhex(stdout,ourpub[i]);
`bwrite(stdout,&co1on,1);
`
`pksize=LONG;
`
`'3'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 157
`
`
`
`C:\cfs-1.3.3\esm.c
`
`433
`
`434
`
`435
`436
`
`437
`
`438
`439
`
`440
`
`441
`442
`443
`444
`
`445
`
`446
`
`447
`
`448
`449
`
`pubstat=O;
`
`pubpos=O;
`
`pubbyte=O;
`state=KEYWAIT;
`
`return 0;
`
`}
`
`s1transpub(1en)
`
`{
`
`}
`
`static unsigned char co1on=':';
`int i;
`
`for (i=0;
`
`i<1en;
`
`i++)
`
`sendhex(fpmaster,ourpub[i]);
`
`bwrite(fpmaster,&co1on,l);
`
`450 masterkeyin(c)
`451
`char c;
`
`452
`453
`454
`
`455
`456
`
`457
`
`458
`
`459
`
`460
`461
`
`462
`
`463
`464
`
`465
`466
`
`467
`
`468
`
`469
`470
`471
`
`472
`
`473
`474
`
`475
`476
`477
`
`478
`479
`
`480
`
`481
`482
`483
`
`484
`485
`
`486
`
`{
`
`int bits;
`
`if (c==':') {
`if (pubpos!=(pk1en))
`
`goto abort;
`
`if (mca1ckeys(pksize)<O)
`
`goto abort;
`
`ciphstate=O;
`state=CIPHER;
`
`/* state = CHECK */
`
`/* add code to do check */
`return;
`
`} else if (pubpos<MAXPUBKEY)
`bits=atoh(c);
`
`{
`
`if (bits<0)
`
`goto abort;
`
`{
`if (pubstat)
`pubbyte |= bits;
`otherpub[pubpos]=pubbyte;
`
`pubpos++;
`
`} else {
`pubbyte = bits<<4;
`
`}
`pubstat = l-pubstat;
`return;
`
`}
`abort:
`
`bwrite(stdout."XXXXXXXXXXXXXXXX",16);
`
`if (paranoid)
`done();
`state=TRANS;
`
`}
`
`int mca1ckeys(1en)
`
`'9'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 158
`
`
`
`C:\cfs-1.3.3\esm.c
`
`487
`
`488
`489
`
`490
`491
`
`492
`493
`
`494
`495
`
`496
`
`497
`498
`
`499
`500
`
`501
`502
`
`503
`504
`
`505
`506
`
`507
`508
`509
`
`510
`511
`
`512
`513
`
`514
`
`515
`516
`517
`518
`
`519
`520
`
`521
`
`522
`
`523
`524
`525
`
`526
`
`527
`528
`
`529
`
`530
`
`531
`532
`
`533
`534
`
`535
`536
`537
`
`538
`539
`540
`
`int len;
`
`int i;
`
`static char kh[32];
`
`if (dhagree(1en,1)<0)
`return -1;
`
`i<8;
`for (i=0;
`iVin[i]=O;
`
`i++)
`
`{
`
`iVout[i]=0xff;
`
`}
`/* TODO
`
`/* sets up session keys */
`
`Sprintf(kh,"KEYHASH=%02X%02x%02X%02x",
`check[0],check[1],check[2],check[3]);
`
`putenv(kh); */
`return 0;
`
`{
`
`}
`
`int s1ca1ckeys(1en)
`int len;
`
`{
`
`}
`
`int i;
`
`if (dhagree(1en,0)<0)
`return -1;
`
`i<8;
`for (i=0;
`iVout[i]=0;
`
`i++)
`
`{
`
`iVin[i]=0xff;
`
`/* sets up session keys */
`
`}
`printf("\r\n(key hash is %02x%02x%02x%02x)\r\n",
`check[0],check[1],check[2],check[3]);
`return 0;
`
`inits1key(param)
`
`int param;
`
`{
`
`}
`
`if ((param<0)
`return -1;
`
`||
`
`(param>2))
`
`pk1en=dhparams[param].primeLen;
`
`pksize=param;
`pubstat=0;
`
`pubpos=0;
`
`pubbyte=0;
`
`s1keyin(c)
`char C;
`
`{
`
`int bits;
`
`if ( ==':') {
`if (pubpos!=pk1en)
`goto abort;
`
`-10-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 159
`
`
`
`C:\cfs-1.3.3\esm.c
`
`541
`542
`
`543
`
`544
`
`545
`546
`
`547
`
`548
`
`549
`550
`
`551
`552
`553
`
`554
`555
`
`556
`
`557
`
`558
`
`559
`560
`
`561
`
`562
`563
`
`564
`565
`566
`
`567
`568
`
`569
`
`570
`571
`
`572
`573
`
`574
`
`575
`
`576
`577
`
`578
`579
`580
`
`581
`582
`583
`
`584
`585
`
`586
`
`587
`588
`
`589
`
`590
`591
`
`592
`593
`
`594
`
`printf("\r\nStarting local key exchange...");
`if (createdh(pksize)<0)
`
`goto abort;
`
`sltranspub(pklen);
`
`printf("calculating DH key...");
`fflush(stdout);
`
`if (slcalckeys(pksize)<O)
`
`goto abort;
`
`printf("Entering ENCRYPTED mode;
`ciphstate=O;
`
`type ctrl-A to escape\r\n");
`
`sloutstate=SL_CRYPT;
`/* add code to send two ascci nulls for check */
`return;
`
`} else if (pubpos<MAXPUBKEY){
`bits=atoh(c);
`
`if (bits<O)
`
`goto abort;
`
`if (pubstat)
`
`{
`
`pubbyte |= bits;
`otherpub[pubpos]=pubbyte;
`
`pubpos++;
`
`} else {
`pubbyte = bits<<4;
`
`}
`pubstat = 1-pubstat;
`return;
`
`}
`abort:
`
`bwrite(stdout,"X",1);
`
`state=SL_START;
`
`}
`
`int cipherout(Ch)
`char ch;
`
`{
`
`int bits;
`
`{
`if (ch=='!')
`ciphstate=O;
`return -1;
`
`}
`bits=atoh(ch);
`
`if (ciphstate) {
`
`ciphbyte |= bits;
`ciphstate=O;
`
`return(cfb8_decrypt(ciphbyte));
`
`} else {
`ciphbyte = bits<<4;
`
`ciphstate=1;
`return -1;
`
`}
`
`-11-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 160
`
`
`
`C:\cfs-1.3.3\esm.c
`
`595
`596
`
`597
`
`598
`
`599
`600
`
`601
`602
`
`603
`604
`
`605
`
`606
`607
`
`608
`
`609
`
`610
`611
`
`612
`613
`
`614
`615
`616
`
`617
`618
`
`619
`620
`
`621
`622
`
`623
`624
`625
`
`626
`627
`
`628
`629
`
`630
`631
`
`632
`633
`634
`
`635
`636
`
`637
`
`638
`639
`
`640
`641
`
`642
`
`643
`
`644
`645
`
`646
`647
`
`648
`
`}
`
`int cipherca1cin(ch)
`
`unsigned char ch;
`
`{
`
`static unsigned char iv[8];
`
`static unsigned int Cbuf;
`int C;
`
`int i;
`
`C = atoh(ch);
`
`switch (cstate) {
`case IVO:
`
`for(i=0;
`
`i<8;
`
`i++)
`
`iV[i]=0;
`
`(C&0xf)<<4;
`Cbuf =
`cstate=IV1;
`
`return '.';
`case IV1:
`
`Cbuf = Cbuf
`iV[7]=cbuf;
`CState=IV2;
`
`return '.';
`case IV2:
`
`|
`
`(c&0xf);
`
`(C&0xf)<<4;
`Cbuf =
`CState=IV3;
`
`return '.';
`case IV3:
`
`Cbuf = Cbuf
`iV[6]=Cbuf;
`cstate=C0;
`
`return '.';
`case C0:
`
`|
`
`(c&0xf);
`
`(C&0xf)<<4;
`Cbuf =
`CState=C1;
`
`return '.';
`case C1:
`
`| c&0xf;
`Cbuf = Cbuf
`c=cfb8_decrypt(cbuf);
`CState=C0;
`
`if (isprint(c)) {
`bwrite(fpmaster,&c,1);
`
`return '_';
`
`} else {
`return '?';
`
`}
`default:
`
`return '?';
`
`}
`
`}
`
`#include <sys/wait.h>
`
`Void
`
`-12-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 161
`
`
`
`C:\cfs-1.3.3\esm.c
`
`649
`
`650
`651
`
`652
`
`653
`654
`
`655
`656
`657
`658
`
`659
`
`660
`
`661
`662
`
`663
`
`664
`665
`666
`
`667
`668
`
`669
`
`670
`671
`
`672
`
`673
`674
`675
`
`676
`
`677
`678
`679
`
`680
`
`681
`682
`
`683
`684
`685
`
`686
`687
`
`688
`689
`
`690
`
`691
`
`692
`693
`
`694
`695
`
`696
`697
`
`698
`699
`
`700
`
`701
`702
`
`finish()
`
`{
`
`}
`
`int status;
`
`register int pid;
`
`register int die = O;
`
`while ((pid = waitpid((pid_t)—1. &status. WNOHANG))
`if (pid == subchild)
`die = 1;
`
`> O)
`
`if (die)
`
`done();
`
`dooutput()
`
`{
`
`register int cc;
`int i;
`
`unsigned char obuf[5l2];
`
`if ((cc = read(master, obuf, 512))
`
`> O)
`
`{
`
`{
`switch (mode)
`case REMOTE:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`domasterout(obuf[i]);
`break;
`case LOCAL:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`dos1aveout(obuf[i]);
`break;
`default:
`
`for (i=0;
`
`i<cc;
`
`i++)
`
`bwrite(stdout, &obuf[i], 1);
`break;
`
`}
`ff1ush(fpmaster);
`ff1ush(stdout);
`
`} else
`done();
`
`}
`
`domasterout(obuf)
`
`unsigned char obuf;
`
`{
`
`int C;
`
`static int count=O;
`
`switch (state) {
`case CIPHER:
`
`c=cfb8_encrypt(obuf);
`if (!(++count % 8))
`
`bwrite(stdout,"!",l);
`
`sendhex(stdout,c);
`break;
`
`-13-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 162
`
`
`
`C:\cfs-1.3.3\esm.c
`
`703
`
`704
`
`705
`706
`
`707
`708
`
`709
`
`710
`711
`
`712
`
`713
`
`714
`
`715
`716
`
`717
`
`718
`719
`
`720
`721
`722
`
`723
`
`724
`725
`
`726
`727
`
`728
`
`729
`730
`
`731
`
`732
`733
`
`734
`735
`
`736
`
`737
`738
`
`739
`
`740
`741
`
`742
`743
`
`744
`
`745
`746
`
`747
`
`748
`749
`
`750
`
`751
`752
`
`753
`
`754
`755
`
`756
`
`case TRANS:
`
`bwrite(stdout, &obuf, 1);
`
`break;
`default:
`
`/* throw away since i/o screws up keying */
`break;
`
`}
`
`}
`
`dos1aveout(obuf)
`
`unsigned char obuf;
`
`{
`
`static int bad=0;
`
`int C;
`
`char ch;
`
`switch (sloutstate) {
`case SL_START:
`bwrite(stdout, &obuf, 1);
`
`if (Obuf==O177)
`
`s1outstate=SL_GOT1;
`break;
`
`case SL_GOT1:
`if (obuf=='~')
`
`s1outstate=SL_GOT2;
`
`else {
`bwrite(stdout, &obuf, 1);
`
`s1outstate=SL_START;
`
`}
`break;
`
`case SL_GOT2:
`if (obuf==O177)
`
`s1outstate=SL_GOT3;
`
`else {
`bwrite(stdout, &obuf, 1);
`
`s1outstate=SL_START;
`
`}
`break;
`
`case SL_GOT3:
`if (obuf=='~')
`
`s1outstate=SL_GOT4;
`
`else {
`bwrite(stdout, &obuf, 1);
`
`s1outstate=SL_START;
`
`}
`break;
`
`case SL_GOT4:
`
`/* key size indicator */
`
`{
`if (obuf=='S')
`inits1key(SHORT) ;
`
`s1outstate=SL_KEYING;
`
`} else if (obu =='M')
`inits1key(MEDIUM);
`
`{
`
`s1outstate=SL_KEYING;
`
`-14-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 163
`
`
`
`C:\cfs-1.3.3\esm.c
`
`757
`758
`
`759
`
`760
`761
`762
`
`763
`764
`
`765
`766
`
`767
`
`768
`769
`
`770
`771
`
`772
`
`773
`774
`
`775
`
`776
`777
`
`778
`779
`
`780
`
`781
`
`782
`783
`
`784
`785
`
`786
`
`787
`
`788
`789
`790
`791
`
`792
`
`793
`
`794
`
`795
`796
`
`797
`
`798
`
`799
`
`800
`
`801
`802
`803
`
`804
`
`805
`
`806
`807
`
`808
`
`809
`810
`
`} else if (obuf=='L')
`initslkey (LONG) ;
`
`{
`
`s1outstate=SL_KEYING;
`
`} else {
`s1outstate=SL_START;
`bwrite(stdout, &obuf, 1);
`
`}
`if (createdh(pksize)<0)
`
`s1outstate=SL_START;
`break;
`
`case SL_KEYING:
`
`if (strchr("0123456789abcdef:",obuf)
`s1keyin(obuf);
`
`!= NULL)
`
`{
`
`} else {
`bwrite(stdout,"U",1);
`
`s1outstate=SL_START;
`
`}
`break;
`
`case SL_CRYPT:
`
`if (strchr("0123456789abcdef!",obuf)
`bad=O;
`
`!= NULL)
`
`{
`
`if ((c = cipherout(obuf))>=0)
`ch=c;
`
`{
`
`bwrite(stdout,&ch,1);
`
`}
`
`{
`} else if (bad++ > 8)
`fprintf(stderr,"\r\nEncrypted session terminated -");
`
`fprintf(stderr,"\r\npress enter for CLEARTEXT mode: ");
`waitenter();
`
`de1key();
`
`s1outstate=SL_START;
`
`} else
`ciphstate=0;
`break;
`default:
`
`bwrite(stdout, &obuf, 1);
`
`break;
`
`}
`
`}
`
`doshe11(mode)
`
`int mode;
`
`{
`
`int t;
`
`/***
`
`t = open(_PATH_TTY, O_RDWR);
`
`if (t >= 0)
`(Void)
`
`{
`iOCtl(t, TIOCNOTTY,
`
`(char *)O);
`
`(Void) c1ose(t);
`
`}
`***/
`
`-15-
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 164
`
`
`
`C:\cfs-1.3.3\esm.c
`
`/* setprompt(mode); */
`gets1ave();
`(Void)
`c1ose(master);
`
`(Void)
`
`(Void)
`
`(Void)
`
`(Void)
`
`dup2(s1ave, O);
`
`dup2(s1ave, 1);
`2);
`
`dup2(s1ave,
`c1ose(s1ave);
`
`if (cmd==NULL)
`
`exec1(she11, "sh",
`
`"—i", O);
`
`else
`
`exec1("/bin/sh", "sh",
`
`II_CII'
`
`cmd, O);
`
`perror(she11);
`fai1();
`
`#ifdef NOTDEF
`
`/* make this work more generally */
`setprompt(mode)
`int mode;
`
`/* TO DO - make this work for csh */
`
`char *o1dpsl;
`
`static char newpsl[l28];
`
`char *getenv();
`
`if ((o1dpsl=getenv("PSl")) == NULL)
`
`o1dpsl="$ ";
`
`{
`switch (mode)
`case LOCAL:
`
`sprintf(newps1,"PS1=ESM:%s",o1dpsl);
`break;
`case REMOTE:
`
`sprintf(newpsl,"PSl=SECURE:%s",o1dpsl);
`break;;
`default:
`
`sprintf(newpsl,"PSl=?esm:%s",o1dpsl);
`break;
`
`}
`putenv(newps1);
`
`} #
`
`endif
`
`rawtty()
`
`{
`
`struct termios sbuf;
`
`sbuf = tt;
`
`sbuf . c_if1ag 42: ~ (INLCR| IGNCR| ICRNL| IXON) ;
`sbuf.c_of1ag &= ~OPOST;
`
`sbuf.c_1f1ag &= ~(ICANON|ISIG|ECHO);
`sbuf.c_cc[VMIN]
`= 1;
`
`= O;
`sbuf.c_cc[VTIME]
`(Void)
`tcsetattr(O, TCSAFLUSH, &sbuf);
`
`811
`
`812
`
`813
`
`814
`
`815
`
`816
`
`817
`
`818
`
`819
`
`820
`
`821
`
`822
`
`823
`
`824
`
`825
`
`826
`
`827
`
`828
`
`829
`
`830
`
`831
`
`832
`
`833
`
`834
`
`835
`
`836
`
`837
`
`838
`
`839
`
`840
`
`841
`
`842
`
`843
`
`844
`
`845
`
`846
`
`847
`
`848
`
`849
`
`850
`
`851
`
`852
`
`853
`
`854
`
`855
`
`856
`
`857
`
`858
`
`859
`
`860
`
`861
`
`862
`
`863
`
`864
`
`-15-
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 165
`
`
`
`C:\cfs-1.3.3\esm.c
`
`865
`866
`
`867
`
`868
`869
`
`870
`871
`
`872
`
`873
`874
`
`875
`
`876
`
`877
`878
`
`879
`
`880
`881
`
`882
`883
`
`884
`
`885
`886
`887
`888
`
`889
`890
`
`891
`892
`893
`
`894
`895
`
`896
`
`897
`898
`
`899
`
`900
`901
`902
`
`903
`
`904
`
`905
`906
`
`907
`
`908
`909
`
`910
`911
`
`912
`913
`
`914
`
`915
`916
`
`917
`918
`
`}
`
`cookedtty()
`
`{
`
`}
`
`(void)
`
`tcsetattr(0. TCSAFLUSH. &tt);
`
`fai1()
`
`{
`
`}
`
`(Void) kill(O, SIGTERM);
`
`done();
`
`done()
`
`{
`
`cookedtty();
`
`{
`switch (mode)
`case REMOTE:
`
`if (state==CIPHER)
`
`printf("XXXXXXXXXXXXXXXX\n") ;
`printf("esm remote ");
`break;
`case LOCAL:
`
`printf("esm local ");
`break;
`
`}
`printf("done\n");
`eXit(O) ;
`
`}
`
`#ifdef PTMX
`
`getmaster()
`
`{
`
`}
`
`if ((master = open("/dev/ptmx", O_RDWR)) == -1)
`return (-1);
`
`if ((s1ave_name =
`
`(char *)ptsname(master)) == NULL ||
`
`un1ockpt(master)
`
`grantpt(master))
`c1ose(master);
`
`||
`
`{
`
`fai1();
`
`}
`(void)
`
`ioct1(master, TIOCFLUSH, NULL);
`
`tcgetattr(0, &tt);
`(void)
`(Void)
`ioct1(0, TIOCGWINSZ,
`
`(char *)&win);
`
`gets1ave()
`
`{
`
`(void) setsid();
`
`if ((s1ave = open(s1ave_name, O_RDWR))
`fai1();
`
`< 0)
`
`{
`
`-17-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 166
`
`
`
`C:\cfs-1.3.3\esm.c
`
`I_PUSH,
`
`IIptemII))
`
`{
`
`I_PUSH,
`
`"1dterm"))
`
`{
`
`I_PUSH,
`
`"ttcompat"))
`
`{
`
`if (ioct1(s1ave,
`fai1();
`
`} i
`
`f (ioct1(s1ave,
`fai1();
`
`} i
`
`f (ioct1(s1ave,
`fai1();
`
`}
`(void)
`
`tcsetattr(s1ave, TCSAFLUSH, &tt);
`
`(void)
`
`ioct1(s1ave, TIOCSWINSZ,
`
`(char *)&win);
`
`#e1se
`
`getmaster()
`
`{
`
`char *pty, *bank, *cp;
`struct stat stb;
`
`pty = &1ine[str1en("/dev/ptyp")];
`
`{
`
`919
`
`920
`
`921
`
`922
`
`923
`
`924
`
`925
`
`926
`
`927
`
`928
`
`929
`
`930
`
`931
`
`932
`
`933
`
`934
`
`935
`
`936
`
`937
`
`938
`
`939
`
`940
`
`941
`
`942
`
`943
`
`944
`
`for (bank = "pqrstuvwxyz"; *bank; bank++)
`1ine[str1en("/dev/pty")] = *bank;
`*pty =
`'0';
`if (stat(1ine, &stb)
`
`< 0)
`
`break;
`
`for (cp = "Ol23456789abcdef"; *cp; cp++)
`*pty = *cp:
`
`{
`
`master = open(1ine, O_RDWR);
`
`{
`if (master >= 0)
`char *tp = &1ine[str1en("/dev/")1;
`int Ok;
`
`/* verify slave side is usable */
`*tp =
`'t';
`
`ok = access(1ine, R_OK|W_OK) == 0;
`*tp =
`'p';
`
`{
`if (ok)
`tcgetattr(O. &tt);
`(void)
`(Void)
`iOCtl(O, TIOCGWINSZ,
`
`(char *)&win);
`return;
`
`} (
`
`void) c1ose(master);
`
`"Out of pty's\n");
`
`}
`
`}
`
`} f
`
`printf(stderr,
`fai1();
`
`} g
`
`{
`
`ets1ave()
`
`945
`
`946
`
`947
`
`948
`
`949
`
`950
`
`951
`
`952
`
`953
`
`954
`
`955
`
`956
`
`957
`
`958
`
`959
`
`960
`
`961
`
`962
`
`963
`
`964
`
`965
`
`966
`
`967
`
`968
`
`969
`
`970
`
`971
`
`972
`
`-18-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 167
`
`
`
`C:\cfs-1.3.3\esm.c
`
`973
`
`974
`
`975
`
`976
`977
`978
`
`979
`980
`
`981
`
`982
`
`983
`
`984
`985
`
`986
`987
`
`1ine[str1en("/dev/")] =
`
`'t';
`
`slave = open(1ine, O_RDWR);
`
`{
`if (slave < 0)
`perror(1ine);
`fai1();
`
`}
`(void)
`
`tcsetattr(s1ave, TCSAFLUSH, &tt);
`
`(void)
`
`ioct1(s1ave, TIOCSWINSZ,
`
`(char *)&win);
`
`(void) setsid();
`
`(void)
`
`ioct1(s1ave, TIOCSCTTY, 0);
`
`}
`
`#endif
`
`988 waitenter()
`
`989
`990
`
`991
`992
`
`993
`994
`
`995
`996
`
`997
`998
`
`999
`
`1000
`1001
`1002
`
`1003
`
`1004
`
`1005
`1006
`
`{
`
`}
`
`unsigned char b;
`
`do {
`
`read(0.&b.1);
`
`} while (b!='\r');
`printf("\r\n");
`
`sendhex(fp,c)
`FILE *fp;
`
`unsigned int C;
`
`{
`
`}
`
`static char buf[l6];
`
`sprintf(buf,"%02x",c);
`
`bwrite(fp,buf,2);
`
`-19-
`
`Petitioner Oracle-Apple — Exhibit 1009 — Page 168
`
`
`
`esm.h
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 169
`
`
`
`C:\cfs-1.3.3\esm.h
`
`/*
`* The author of this software is Matt Blaze.
`
`*
`
`Copyright
`
`(c) 1995 by AT&T.
`
`* Permission to use, Copy, and modify this software without fee
`
`* is hereby granted, provided that this entire notice is included in
`
`* all copies of any software which is or includes a copy or
`
`* modification of this software and in all copies of the supporting
`* documentation for such software.
`*
`
`* This software is subject to United States export controls.
`*
`
`* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
`
`IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
`* WARRANTY.
`* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
`
`* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
`
`*/
`
`typedef struct {
`char ekl[l28];
`
`char ek2[l28];
`
`char ek3[128];
`
`} keystr;
`extern keystr ks;
`
`extern unsigned char check[8];
`
`unsigned int cfb8_encrypt();
`
`unsigned int cfb8_decrypt();
`extern R_RANDOM_STRUCT rs;
`
`extern R_DH_PARAMS dhparams[];
`extern unsigned char iVin[],
`iVout[];
`
`extern unsigned char otherpub[];
`
`extern unsigned char ourpub[];
`
`extern unsigned char ourpriv[];
`
`extern int ourprivlen;
`
`extern int pklen;
`
`#define SHORT O
`
`#define MEDIUM 1
`
`#define LONG 2
`
`#define MAXPUBKEY 512
`
`1
`2
`
`3
`
`4
`
`5
`
`6
`
`7
`8
`9
`
`10
`11
`
`12
`
`13
`14
`
`15
`
`16
`17
`
`18
`19
`
`20
`
`21
`
`22
`23
`
`24
`
`25
`
`26
`27
`
`28
`29
`
`30
`
`31
`
`32
`
`33
`
`34
`35
`
`36
`
`37
`
`38
`39
`
`40
`41
`
`'1'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 170
`
`
`
`esm_cipher.c
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 171
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`/*
`
`* ESM crypto interface
`* V0.6
`
`*/
`
`/*
`* The author of this software is Matt Blaze.
`
`*
`
`Copyright
`
`(c) 1995 by AT&T.
`
`* Permission to use, Copy, and modify this software without fee
`>(-
`
`is hereby granted, provided that this entire notice is included in
`
`* all copies of any software which is or includes a copy or
`
`* modification of this software and in all copies of the supporting
`* documentation for such software.
`*
`
`* This software is subject to United States export controls.
`*
`
`* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
`
`IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
`* WARRANTY.
`* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
`
`* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
`
`* /
`#include <stdio.h>
`
`#include <sys/types.h>
`
`#include <sys/time.h>
`
`#include <signal.h>
`
`#include "global.h"
`#include "rsaref.h"
`
`#include "esm.h"
`
`unsigned char check[8];
`
`unsigned char skeyl[8];
`
`unsigned char skey2[8];
`
`unsigned char skey3[8];
`
`unsigned char mkeyl[8];
`
`unsigned char mkey2[8];
`
`unsigned char mkey3[8];
`
`unsigned char ivin[8];
`
`unsigned char ivout[8];
`
`R_RANDOM_STRUCT rs ;
`
`R_DH_PARAMS dhparams[3];
`
`unsigned char otherpub[MAXPUBKEY+2];
`
`unsigned char ourpub[MAXPUBKEY+2];
`
`unsigned char ourpriv[MAXPUBKEY];
`
`int ourprivlen;
`
`int pklen;
`
`keystr inks, outks;
`
`cipherinit(master)
`int master;
`
`1
`
`2
`3
`
`4
`
`5 6
`
`7
`
`8
`
`9
`i-' O
`
`11
`
`12
`13
`14
`
`15
`16
`
`17
`
`18
`19
`
`20
`
`2 1
`22
`
`23
`
`24
`
`25
`
`26
`27
`
`28
`29
`
`30
`31
`
`32
`
`33
`
`34
`
`35
`
`36
`
`37
`
`38
`
`39
`40
`
`4 1
`42
`
`43
`44
`
`45
`
`46
`
`47
`
`48
`
`49
`50
`
`51
`52
`
`53
`54
`
`'1'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 172
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`55
`
`56
`
`57
`
`58
`
`59
`
`60
`
`61
`
`62
`
`63
`
`64
`
`65
`
`66
`
`67
`
`68
`
`69
`
`70
`71
`
`72
`
`73
`74
`
`75
`
`76
`77
`
`78
`
`79
`
`80
`
`81
`
`82
`
`83
`
`84
`
`85
`
`86
`
`87
`
`88
`
`89
`
`90
`
`91
`
`92
`
`93
`
`94
`
`95
`
`96
`
`97
`
`98
`
`99
`
`100
`
`101
`
`102
`
`103
`
`104
`
`105
`
`106
`
`107
`
`108
`
`{
`
`{
`if (master)
`des_key_setup(skeyl,inks.ek1);
`
`des_key_setup(skey2,inks.ek2);
`
`des_key_setup(skey3,inks.ek3);
`
`des_key_setup(mkeyl,outks.ekl);
`
`des_key_setup(mkey2,outks.ek2);
`
`des_key_setup(mkey3,outks.ek3);
`
`} else {
`des_key_setup(skeyl,outks.ekl);
`
`des_key_setup(skey2,outks.ek2);
`
`des_key_setup(skey3,outks.ek3);
`
`des_key_setup(mkeyl,inks.ekl);
`
`des_key_setup(mkey2,inks.ek2);
`
`des_key_setup(mkey3,inks.ek3);
`
`/* 8 bit Cfb encrypt */
`
`unsigned int Cfb8_enCrypt(C)
`unsigned int C;
`
`int i;
`
`Char b1k[8];
`
`for (i=0;
`
`i<8;
`
`i++)
`
`b1k[i]=ivout[i];
`
`des_b1oCk_Cipher(outks.ekl,b1k,O);
`
`des_b1oCk_Cipher(outks.ek2,b1k,1);
`
`des_b1oCk_Cipher(outks.ek3,b1k,O);
`for (i=0;
`i<7;
`i++)
`
`iVout[i]=iVout[i+l];
`
`= b1k[0]
`iVout[7]
`return (ivout[7]);
`
`A C;
`
`/9:
`
`* 8 bit Cfb decrypt
`*/
`
`unsigned int Cfb8_deCrypt(C)
`unsigned int C;
`
`int i;
`
`unsigned Char b1k[8];
`
`for (i=0;
`
`i<8;
`
`i++)
`
`b1k[i]=ivin[i];
`
`des_b1oCk_Cipher(inks.ekl,b1k,O);
`
`des_b1oCk_Cipher(inks.ek2,b1k,1);
`
`des_b1oCk_Cipher(inks.ek3,b1k,O);
`for (i=0;
`i<7;
`i++)
`
`ivin[i]=ivin[i+1];
`
`iVin[7]
`
`= C;
`
`'2'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 173
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`109
`
`110
`111
`
`112
`
`113
`
`114
`115
`116
`
`117
`
`118
`119
`120
`
`121
`122
`
`123
`124
`125
`
`126
`
`127
`128
`
`129
`
`130
`
`131
`
`132
`
`133
`
`134
`135
`
`136
`
`137
`138
`
`139
`
`140
`
`141
`
`142
`143
`
`144
`
`145
`
`146
`147
`
`148
`
`149
`
`150
`
`151
`
`152
`
`153
`154
`155
`
`156
`157
`158
`
`159
`
`160
`
`161
`162
`
`return (b1k[O]
`
`A C);
`
`}
`
`/*
`
`* alpha —> hex; used for encoding
`
`(ascii only — bfd)
`
`*
`*/
`int atoh(ch)
`
`int ch;
`
`{
`
`}
`
`if (isdigit(ch))
`return ch—'O';
`
`if (islower(ch))
`return 10+ch—'a';
`
`if (isupper(ch))
`return 10+Ch—'A';
`
`else
`
`return -1;
`
`/*???*/
`
`int count=O;
`
`int secs;
`
`unsigned int bits;
`
`void procbit()
`
`{
`
`}
`
`secs-—;
`
`bits |= ((count ‘
`
`(count>>4)) & 0xf)<<(secs*4);
`
`{
`if (secs)
`alarm(1);
`
`signal(SIGALRM,procbit);
`
`getuid();
`
`/* do a syscall to slow things a bit */
`
`}
`
`int verbose=1;
`
`/*
`
`* init the random number generator — seed with
`* truerandbits.
`
`* Use a combination of OS load and processor clock skew to get
`
`* enough entropy to generate the secret parameter
`
`(we only need a
`
`* total of 128 or so bits, so we just get more than we need to
`
`* compensate for any non-randomness).
`
`* WARNING: use oldrand()
`
`(below) on new platforms
`
`* if you aren't sure about truerand().
`*/
`randinit()
`
`{
`
`unsigned int n;
`int i;
`
`struct timeval tv;
`
`unsigned long truerand();
`
`unsigned char b[20];
`
`'3'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 174
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`163
`
`164
`165
`166
`
`167
`168
`
`169
`
`170
`171
`
`172
`
`173
`
`174
`175
`
`176
`
`177
`178
`179
`
`180
`
`181
`182
`
`183
`184
`
`185
`
`186
`
`187
`
`188
`
`189
`190
`191
`
`192
`193
`
`194
`
`195
`196
`
`197
`198
`199
`
`200
`201
`
`202
`203
`
`204
`205
`
`206
`
`207
`208
`
`209
`210
`
`211
`212
`
`213
`214
`215
`
`216
`
`R_RandomInit(&rs);
`
`{
`if (verbose)
`fprintf(stderr,"randomizing...");
`fflush(stderr);
`
`}
`/* we just grab 160 truerand bits and keep feeding them
`
`over and over to R_RandomUpdate until it's happy */
`
`i++)
`i<2o;
`for (i=0;
`b[i]=randbyte();
`
`{
`
`fprintf(stderr,".");
`
`}
`
`while (R_GetRandomBytesNeeded(&n,&rs),
`R_RandomUpdate(&rs,b,sizeof(b));
`
`(n>0))
`
`{
`
`}
`
`{
`if (verbose)
`fprintf(stderr,"done\n");
`fflush(stderr);
`
`}
`
`}
`
`/*
`* OLD CODE HERE.
`
`NOT CALLED.
`
`* generate 8 random clock skew bits
`
`* we don't use this anymore..
`
`instead we generate more
`
`* bits using the mitchell code.
`
`* modify the code to use this instead if you don't trust
`
`the higher—bandwidth mitchell numbers.
`
`*
`*/
`int rnd8()
`
`secs=2;
`
`bits=O;
`
`signa1(SIGALRM,procbit);
`a1arm(1);
`
`getpid();
`while (secs)
`Count++;
`
`return bits;
`
`{
`
`}
`
`/*
`* OLD CODE HERE.
`
`NOT CALLED.
`
`* this is the old, slow but simple truerand routine
`
`* you should change the code use this on new platforms instead of
`*
`the "randinit" above.
`
`*/
`oldrandinit()
`
`{
`
`unsigned int n;
`
`unsigned char b[18];
`struct timeval tv;
`
`R_RandomInit(&rs);
`
`'4'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 175
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`217
`218
`
`219
`
`220
`221
`
`222
`
`223
`224
`
`225
`226
`
`227
`228
`229
`
`230
`
`231
`
`232
`233
`234
`
`235
`
`236
`237
`238
`
`239
`240
`
`241
`242
`
`243
`
`244
`245
`
`246
`
`247
`
`248
`
`249
`
`250
`
`251
`
`252
`
`253
`254
`
`255
`256
`
`257
`258
`
`259
`
`260
`261
`262
`
`263
`264
`
`265
`
`266
`
`267
`268
`269
`
`270
`
`/* but we ignore */
`R_GetRandomBytesNeeded(&n,&rs);
`/* RSAREF wants 256 bytes, which is an awful lot at 4bps.
`
`we
`
`really only need enough to do justice to the entropy of
`
`the block cipher (3des), so we just generate 18. */
`
`if (verbose)
`
`fprintf(stderr,"Randomizing (takes about 45 secs)...");
`fflush(stderr);
`
`for (n=O; n<18; n++)
`b[n]=rnd8();
`
`{
`
`if (verbose && (n%4==3))
`fprintf(stderr,".");
`fflush(stderr);
`
`{
`
`}
`
`}
`
`while (R_GetRandomBytesNeeded(&n,&rs),
`R_RandomUpdate(&rs,b,18);
`if (verbose)
`
`(n>O))
`
`{
`
`fprintf(stderr,".");
`
`}
`/* Just for good measure, we throw in a couple other things */
`n=getpid()7
`
`R_RandomUpdate(&rs,(unsigned char*)&n,sizeof(n));
`gettimeofday(&tv,NULL);
`
`R_RandomUpdate(&rs,(unsigned char*)&tv,sizeof(tv));
`if (verbose)
`
`fprintf(stderr,"done\n");
`
`}
`
`#define BLANKLINE O
`
`#define TERM 1
`
`#define NONE 2
`
`#define SHORTKEY 3
`
`#define MEDKEY 4
`
`#define LONGKEY 5
`
`#define HEX 6
`
`#define FILENAME 7
`
`int size[3];
`
`int keysize=O;
`
`getpubkey()
`
`{
`
`}
`
`fprintf(stderr,"Calculator not
`return;
`
`implemented, sorry\n");
`
`createdh(param)
`
`int param;
`
`{
`
`int e;
`
`if ((param<O)
`
`||
`
`(param>2))
`
`'5'
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 176
`
`
`
`C:\cfs-1.3.3\esm_cipher.c
`
`return -1;
`
`ourpriv1en=(dhparams[param].generatorLen)/2;
`
`/* from gen'd params */
`
`if ((e=R_SetupDHAgreement(ourpub, ourpriv, ourprivlen,
`
`&dhparams[param], &rs))!=O)
`
`{
`
`return -1;
`
`}
`re turn 0 7
`
`dhagree(param,master)
`
`int param;
`int master;
`
`{
`
`}
`
`unsigned char buf[MAXPUBKEY];
`int
`i;
`
`if ((param<O)
`return -1;
`
`||
`
`(param>2))
`
`if (R_ComputeDHAgreedKey(buf,otherpub,ourpriv,ourpriv1en,
`O)
`&dhparams[param])
`return -1;
`
`i<8;
`for (i=0;
`mkeyl[i]
`
`{
`i++)
`buf[i];
`
`/* always have enough agreed bits */
`
`mkey2[i]
`
`mkey3[i]
`
`skey1[i]
`
`skey2[i]
`
`skey3[i]
`check[i]
`
`buf[i+8];
`
`buf[i+16];
`
`buf[24+i];
`
`buf[24+i+8];
`
`buf[24+i+16];
`
`buf[32+i];
`
`}
`cipherinit(master);
`re turn 0 7
`
`de1key()
`
`{ }
`
`271
`
`272
`
`273
`274
`
`275
`
`276
`277
`
`278
`
`279
`
`280
`
`281
`
`282
`
`283
`
`284
`
`285
`
`286
`
`287
`
`288
`
`289
`
`290
`
`291
`
`292
`
`293
`
`294
`
`295
`
`296
`
`297
`
`298
`
`299
`
`300
`
`301
`
`302
`
`303
`
`304
`
`305
`
`306
`
`307
`
`308
`
`309
`
`310
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 177
`
`
`
`esm_gen.c
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 178
`
`
`
`C:\cfs-1.3.3\esm_gen.c
`
`/9:
`* ESM DH parameter generator
`
`*/
`
`/*
`* The author of this software is Matt Blaze.
`
`*
`
`Copyright
`
`(c) 1995 by AT&T.
`
`* Permission to use, Copy, and modify this software without fee
`
`* is hereby granted, provided that this entire notice is included in
`
`* all copies of any software which is or includes a copy or
`
`* modification of this software and in all copies of the supporting
`* documentation for such software.
`
`* This software is subject to United States export controls.
`
`* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
`* WARRANTY.
`
`IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
`* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
`
`* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
`
`#include <stdio.h>
`
`#include "global.h"
`#include "rsaref.h"
`
`#include "esm.h"
`
`main()
`
`{
`
`R_DH_PARAMS dhparams[3];
`unsigned char pO[5l2],pl[5l2],p2[5l2],g0[5l2],gl[5l2],g2[5l2];
`int x;
`
`randinit();
`
`fprintf(stderr,"Generating 512\n");
`
`dhparams[O].prime=pO;
`
`dhparams[O].generator=gO;
`
`if (x=R_GenerateDHParams(&dhparams[O],512,256,&rs))
`fprintf(stderr,"failed %x\n",x);
`
`fprintf(stderr,"Generating 768\n");
`
`dhparams[l].prime=pl;
`
`dhparams[l].generator=gl;
`
`if (x=R_GenerateDHParams(&dhparams[1],768,384,&rs))
`fprintf(stderr,"failed %x\n",x);
`
`fprintf(stderr,"Generating l024\n");
`dhparams[2].prime=p2;
`
`dhparams[2].generator=g2;
`
`if (x=R_GenerateDHParams(&dhparams[2],lO24,5l2,&rs))
`fprintf(stderr,"failed %x\n",x);
`
`fprintf(stderr,"Printing\n");
`
`printparams(dhparams);
`exit(O);
`
`i-'OkO<D\'iO\U'|i-i>UJ[\Ji-'
`
`i-' i-'
`
`i-' l\.)
`
`i-' (A)
`i-' i-l>
`
`i-' U'|
`i-' ON
`I-' \'i
`I-' (D
`i-' KO
`[\J O
`l\.) I-'
`
`[\J [\J
`
`[\J Us)
`l\.) i-i>
`
`[\.) U'|
`[\J ON
`I\.) \'i
`
`[\J (D
`
`29
`
`30
`
`31
`
`32
`
`33
`
`34
`
`35
`
`36
`
`37
`
`38
`
`39
`
`40
`41
`
`42
`
`43
`44
`
`45
`
`46
`47
`
`48
`
`49
`
`50
`
`51
`
`52
`
`53
`
`54
`
`Petitioner Oracle-Apple - Exhibit 1009 - Page 179
`
`
`
`C:\cfs-1.3.3\esm_gen.c
`
`printparams(dh