示例#1
0
文件: dump.c 项目: kahrs/cda
int
domanu(uchar *name, uchar *data, int ndata)
{
	long addr;
	uchar *rec;
	int col;

	if(debug){
		col = printcol+16;
		Bprint(out, "%s\t", name);
		while(printcol < col) {
			printcol += 8;
			Bprint(out, "\t");
		}
		hout(data, ndata);
		Bprint(out, "\n");
	}
	addr = LONG(data);
	if(addr < 4)
		return 0;
	manuf = name;
	rec = getrec(addr);
	dorec(rec, dopart, 18);
	free(rec);
	return 0;
}
示例#2
0
文件: dump.c 项目: kahrs/cda
int
dopart(uchar *name, uchar *data, int ndata)
{
	long addr0, addr1, family, pinout, devbits, notes;
	int col, j, k = 0;
	Devmask *db;

	if(data[13] == 0x02)	/* is this correct? */
		k = 2;
	if(!debug && name[0] == ' ')
		return k;
	addr0 = LONG(data+0);
	addr1 = LONG(data+4);
	family = SHORT(data+8);
	pinout = SHORT(data+10);
	devbits = data[12];
	notes = data[15];
	if(!(devbits & devices))
		return k;
	devbits &= devices|Hflag;
	if(manuf){
		col = printcol+16;
		Bprint(out, "%s\t", manuf);
		while(printcol < col) {
			printcol += 8;
			Bprint(out, "\t");
		}
	}
	col = printcol+16;
	Bprint(out, "%s\t", name);
	while(printcol < col) {
		printcol += 8;
		Bprint(out, "\t");
	}
	if(debug){
		Bprint(out, "%8.8ux %8.8ux %4.4ux %4.4ux %2.2ux ",
			addr0, addr1, family, pinout, devbits);
		hout(data+13, ndata+k-13);
		if(out2){
			Bprint(out2, "%8.8ux 0\n", addr0);
			Bprint(out2, "%8.8ux 1\n", addr1);
		}
	}else{
		Bprint(out, "%4.4ux %4.4ux", family, pinout);
		if(!sflag)
			for(j=0,db=devmasks; db->mask; db++){
				if((db->mask&devbits) == db->mask){
					Bprint(out, "%c%s",
						j++?',':'\t', db->name);
					devbits &= ~db->mask;
				}
			}
		if(notes)
			Bprint(out, "\t%d", notes);
	}
	Bprint(out, "\n");
	return k;
}
示例#3
0
文件: dump.c 项目: kahrs/cda
int
dumpit(uchar *name, uchar *data, int ndata)
{
	int col, k = 0;

	if(ndata > 6)
		return dopart(name, data, ndata);
	col = printcol+16;
	Bprint(out, "%s\t", name);
	while(printcol < col) {
		printcol += 8;
		Bprint(out, "\t");
	}
	hout(data, ndata+k);
	Bprint(out, "\n");
	return k;
}
示例#4
0
int main(int argc,char *argv[]){
  int i,j,k,count=0;
  unsigned char inv_x[N],o;
  unsigned char a[N],b[N],inv_b[N],c[N];
  time_t t;
  FILE *fp,*fo;
  set fai;
  arrayn p,aa;
  array8 q;

  
  unsigned char cipher[4];
  unsigned char temp[N];
  unsigned char inv_c[16][N];
  
  unsigned char test[32]={1,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0};
  unsigned char ee[4];
  unsigned int t2=0,l=0;
  char m[1];

  unsigned char u[N/2],tmp[N],tmb[N];
  unsigned char inv_t[16][N];
  unsigned char nx[N];

  arrayul pp;
  array16 tt;

  seed();
  pp=crand(password);
  for(i=0;i<8;i++)
    printf("%llu\n",pp.u[i]);

  hout();

  //  mainga(argc,argv);
  exit(1);

  
  tt=hash(argc,argv);
  for(i=0;i<16/2;i++)
    printf("%08x ",tt.h[i]);
  printf("\n");

  

  srand(time(&t));

  //    chksalt();
       gendata();
  exit(1);
  
  for(i=0;i<N/2;i++){
    u[i]=rand()%256;
    printf("%u\n",u[i]);
  }


  printf("input mode\n");
  scanf("%s",&m);

  if(strcmp(m,"k")==0)
    keygen();
  if(strcmp(m,"d")==0){
    fp=fopen("braidsec.key","rb");
    fread(nx,1,N,fp);
    fclose(fp);
  }
  if(strcmp(m,"e")==0){
    fp=fopen("braidpub.key","rb");
    fread(pr,1,N,fp);
    fread(ps,1,N,fp);
    /*
   for(i=0;i<N;i++)
     printf("%d,",s[i]);
   printf("\n");
   */
    fclose(fp);
  }


  char file[100],out[100];
  int f;
  unsigned char buf[64];
  unsigned char h[N],rr[N];
  
  for(i=0;i<N;i++)
    h[i]= r[i];
  
  printf("\ninput file name\n");
  scanf("%s",&file);
  fp=fopen(file,"rb");
  printf("input outfile name\n");
  scanf("%s",&out);
  fo=fopen(out,"wb");
 

  j=0;

  if(strcmp("d",m)==0){
    for(i=0;i<N;i++)
      inv_b[nx[i]]=i;
    for(i=0;i<N;i++)
      pr[i]=nx[r[inv_b[i]]];
    for(i=0;i<N;i++)
      ps[i]=nx[s[inv_b[i]]];
  }

  for(i=0;i<N;i++)
    rr[i]=rand()%256;


  if(strcmp(m,"e")==0){
    fai=session(rr);
    
    for(i=0;i<N;i++)
      printf("%d,",fai.b[i]);
    printf("\n");
    
    fwrite(fai.a,1,64,fo);
  }


  if(strcmp(m,"d")==0){
    fread(fai.a,1,64,fp);
    for(k=0;k<N;k++){
      c[k]=nx[fai.a[inv_b[k]]];
      printf("%d,",c[k]);
    }
    printf("aaa\n");
  }

while((f=fread(buf,1,64,fp))>0){

  if(strcmp("e",m)==0){
    p=chash(fai.b);
    /*
    for(i=0;i<N;i++)
      printf("%d,",p.ar[i]);
    printf("\n");
    */
    for(k=0;k<N;k++)
      rr[k]=p.ar[k];
    fai=session(rr);
    for(k=0;k<N;k++)
      buf[k]^=p.ar[k];
  }
  if(strcmp("d",m)==0){
  /*
    for(i=0;i<N;i++)
      printf("%d,",c[i]);
    printf("vv\n");
    //        exit(1);
    */
    p=chash(c);
    
    for(k=0;k<N;k++){
      buf[k]^=p.ar[k];
      rr[k]=p.ar[k];
    }
    fai=session(rr);
    /*
    for(i=0;i<N;i++)
      printf("%d,",p.ar[i]);
    printf("bb\n");
    */
    //    exit(1);
    for(k=0;k<N;k++)
      c[k]=fai.b[k];
    
  }
  fwrite(buf,1,f,fo);

 }

 fclose(fp);
 fclose(fo);


return 0;
}
示例#5
0
/* MDSRMDEF: Process short reference mapping declaration.
*/
VOID mdsrmdef(UNCH *tbuf)     /* Work area for tokenization[LITLEN+2]. */
{
     struct entity *entcb;    /* Ptr to defined entity. */
     PSRH srhptr;             /* Ptr to short reference map hdr (in srhtab).*/
     int srn;                 /* Short reference delimiter number in srdeltab.*/
     int mapused = 0;	      /* Has map already been used? */

     mdname = key[KSHORTREF]; /* Identify declaration for messages. */
     subdcl = NULL;           /* No subject as yet. */
     parmno = 0;              /* No parameters as yet. */
     if (!sd.shortref) {mderr(198, (UNCH *)0, (UNCH *)0); return;}
     mdessv = es;             /* Save es for checking entity nesting. */
     /* PARAMETER 1: SHORTREF map name.
     */
     pcbmd.newstate = 0;
     parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN);
     TRACEMD("1: map nm");
     if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
     if ((srhptr = srhfind(tbuf))!=0) {
	  mapused = 1;
	  /* Error if map was declared (not just used). */
	  if (SRM(0)) {mderr(56, tbuf+1, (UNCH *)0); return;}
     }
     else srhptr = srhdef(tbuf);  /* Create map with SRs mapped to NULL.*/
     SRM(0) = (PECB)srhptr;       /* Indicate map was actually declared.*/
     subdcl = srhptr->ename+1;    /* Save map name for error msgs. */

     while ( pcbmd.newstate = 0,
             parsemd(tbuf, NAMECASE, &pcblitp, SRMAXLEN)==LIT
          || pcbmd.action==LITE ) {
          /* PARAMETER 2: Delimiter string.
          */
          TRACEMD("2: SR string");
          if ((srn = mapsrch(lex.s.dtb, tbuf))==0) {
               mderr(124, tbuf, (UNCH *)0);
               goto cleanup;
          }
          /* PARAMETER 3: Entity name.
          */
          pcbmd.newstate = 0;
          parsemd(tbuf, ENTCASE, &pcblitp, NAMELEN);
          TRACEMD("3: entity");
          if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); goto cleanup;}
          if ((entcb = entfind(tbuf))==0) {
	       union etext etx;
	       etx.x = 0;
               entcb = entdef(tbuf, '\0', &etx);
	  }
          if (SRM(srn)) {
               mderr(56, (srn<lex.s.prtmin ? (UNCH *)lex.s.pdtb[srn]
                                       : lex.s.dtb[srn].mapnm), (UNCH *)0);
               continue;
          }
          SRM(srn) = entcb;
          if (srn>=lex.s.fce && srn!=lex.s.hyp && srn!=lex.s.hyp2
	      && srn!=lex.s.lbr && srn!=lex.s.rbr)
               lexcnm[*lex.s.dtb[srn].mapnm] = lex.l.fce;
          else if (srn==lex.s.spc) lexcnm[' '] = lex.l.spcr;
     }
     /* PARAMETER 4: End of declaration.
     */
     TRACEMD(emd);
     if (parmno==2)
          {mderr((UNS)(pcbmd.action==EMD ? 28:123), (UNCH *)0, (UNCH *)0); goto cleanup;}
     if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
     if (es!=mdessv) synerr(37, &pcbmd);
     ++ds.srcnt;
     TRACESRM("SHORTREF", srhptr->srhsrm, (UNCH *)0);
     return;

 cleanup:
     /* Don't free the map if the map was in use (because of a USEMAP
	declaration) before this declaration. */
     if (mapused)
	  MEMZERO((UNIV)srhptr->srhsrm, sizeof(PECB)*(lex.s.dtb[0].mapdata+1));
     else {
          frem((UNIV)srhptr->srhsrm);
          hout((THASH)srhtab, srhptr->ename, 0);
          frem((UNIV)srhptr);
     }
}
示例#6
0
/* MDENTITY: Process ENTITY declaration.
*/
VOID mdentity(UNCH *tbuf)     /* Work area for tokenization[LITLEN+2]. */
{
     struct fpi fpicb;        /* Formal public identifier structure. */
     struct fpi *fpis = &fpicb;  /* Ptr to current or #DEFAULT fpi. */
     union etext etx;         /* Ptr to entity text. */
     UNCH estore = ESM;       /* Entity storage class. */
     struct entity *ecb;      /* Ptr to entity control block. */
     int parmsw = 0;          /* 1=parameter entity declaration; 0 = not. */
     int defltsw = 0;         /* 1=#DEFAULT declaration; 0=not. */
     PNE pne = 0;             /* Ptr to N/C/SDATA entity control block. */

     mdname = key[KENTITY];  /* Declaration name for messages. */
     subdcl = NULL;           /* No subject as yet. */
     parmno = 0;              /* No parameters as yet. */
     mdessv = es;             /* Save es for checking entity nesting. */
     /* PARAMETER 1: Entity name.
     */
     pcbmd.newstate = 0;
     parsemd(nmbuf, ENTCASE, &pcblitp, NAMELEN);
     TRACEMD("1: entity nm");
     switch (pcbmd.action) {
     case PEN:
          parsemd(nmbuf + 1, ENTCASE, &pcblitp, NAMELEN);
          if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;}
	  if (nmbuf[1] == NAMELEN + 2) {
	       /* It was too long. */
	       nmbuf[0] = NAMELEN + 2;
	       nmbuf[NAMELEN + 1] = '\0';
	       mderr(65, (UNCH *)0, (UNCH *)0);
	  }
	  else
	       nmbuf[0] = nmbuf[1] + 1;	/* Increment length for PERO. */
          nmbuf[1] = lex.d.pero;        /* Prefix PERO to name. */
          parmsw = 1;                   /* Indicate parameter entity. */
     case NAS:
          break;
     case RNS:           /* Reserved name started. */
          if (ustrcmp(nmbuf+1, key[KDEFAULT])) {
               mderr(118, nmbuf+1, key[KDEFAULT]);
               return;
          }
          memcpy(nmbuf, indefent, *indefent);/* Copy #DEFAULT to name buffer. */
          fpis = &fpidf;                /* Use #DEFAULT fpi if external. */
          defltsw = 1;                  /* Indicate #DEFAULT is being defined.*/
          break;
     default:
          mderr(122, (UNCH *)0, (UNCH *)0);
          return;
     }
     subdcl = nmbuf+1;                  /* Subject name for error messages. */
     /* PARAMETER 2: Entity text keyword (optional).
     */
     pcbmd.newstate = 0;
     parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
     TRACEMD("2: keyword");
     switch (pcbmd.action) {
     case NAS:
          if ((estore = (UNCH)mapsrch(enttab, tbuf+1))==0) {
	       estore = parmsw ? ESP : ESF;
               pne = (PNE)rmalloc(NESZ);
               if (mdextid(tbuf, fpis, nmbuf+1+parmsw, &estore, pne)==0)
		    return;
               if (defltsw) etx.x = NULL;
               else if ((etx.x = entgen(&fpicb))==0) {
		    if (parmsw)
		         mderr(148, nmbuf+2, (UNCH *)0);
		    else
		         mderr(147, nmbuf+1, (UNCH *)0);
	       }
               goto parm4;
          }
          if (parmsw && (estore==ESX || estore==ESC)) {
               mderr(38, tbuf+1, (UNCH *)0);
               estore = ESM;
          }
          pcbmd.newstate = 0;
          parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
          break;
     default:
          estore = ESM;
          break;
     }
     /* PARAMETER 3: Parameter literal.
     */
     TRACEMD("3: literal");
     switch (pcbmd.action) {
     case LITE:
     case LIT:
          switch (estore) {
          case ESM:           /* LITERAL: parameter literal required. */
          case ESC:           /* CDATA: parameter literal required. */
          case ESX:           /* SDATA: parameter literal required. */
          case ESI:           /* PI: parameter literal required. */
               etx.c = savestr(tbuf);
               break;
          case ESMD:          /* MD: parameter literal required. */
               etx.c = sandwich(tbuf, lex.m.mdo, lex.m.mdc); 
	       goto bcheck;
          case ESMS:          /* MS: parameter literal required. */
               etx.c = sandwich(tbuf, lex.m.mss, lex.m.mse);
	       goto bcheck;
          case ESS:           /* STARTTAG: parameter literal required. */
	       etx.c = sandwich(tbuf, lex.m.stag, lex.m.tagc);
	       goto bcheck;
          case ESE:           /* ENDTAG: parameter literal required. */
	       etx.c = sandwich(tbuf, lex.m.etag, lex.m.tagc);
	  bcheck:
	       if (etx.c == 0) {
		    mderr(225, (UNCH *)0, (UNCH *)0);
		    return;
	       }
               break;
          }
          break;
     default:
          mderr(123, (UNCH *)0, (UNCH *)0);
          return;
     }
     /* PARAMETER 4: End of declaration.
     */
     pcbmd.newstate = 0;
     parsemd(tbuf, NAMECASE, &pcblitp, LITLEN);
     parm4:
     TRACEMD(emd);
     if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0);
     if (es!=mdessv) synerr(37, &pcbmd);

     /* EXECUTE: If the entity already exists, ignore the new definition.
                 If it is a new entity, store the definition.
     */
     if ((ecb = entfind(nmbuf))!=0 && ecb->estore) {
	  if (ecb->dflt) {
	       mderr(228, nmbuf + 1, (UNCH *)0);
	       hout((THASH)etab, nmbuf, hash(nmbuf, ENTHASH));
	       if (ecb->estore == ESN) {
		    frem((UNIV)NEID(ecb->etx.n));
		    frem((UNIV)ecb->etx.n);
	       }
	       else if (ecb->estore >= ESFM)
		    frem((UNIV)ecb->etx.x);
	       frem((UNIV)ecb);
	  }
	  else {
	       /* Duplicate definition: not an error. */
	       if (sw.swdupent) mderr(68, nmbuf+1, (UNCH *)0);
	       if (estore<ESFM) frem((UNIV)etx.c);
	       return;
	  }
     }
     ++ds.ecbcnt;                       /* Do capacity before NOTATION. */
     ds.ecbtext += estore<ESFM ? ustrlen(etx.c) : entlen;
     ecb = entdef(nmbuf, estore, &etx); /* Define the entity. */
     if (estore==ESN) {                 /* If entity is external: */
          NEENAME(pne) = ecb->ename;    /* Store entity name in ne. */
          NEID(pne) = etx.x;            /* Store system fileid in ne. */
	  NESYSID(pne) = fpis->fpisysis ? savestr(fpis->fpisysis) : 0;
	  NEPUBID(pne) = fpis->fpipubis ? savestr(fpis->fpipubis) : 0;
          ecb->etx.n = pne;             /* Store ne control block in etx. */
          TRACEESN(pne);
     }
     else if (pne)
	  frem((UNIV)pne);
     if (defltsw) {
	  ecbdeflt = ecb;     /* If #DEFAULT save ecb. */
	  if (fpidf.fpipubis)
	       fpidf.fpipubis = savestr(fpidf.fpipubis);
	  if (fpidf.fpisysis)
	       fpidf.fpisysis = savestr(fpidf.fpisysis);
     }
}
示例#7
0
文件: dump.c 项目: kahrs/cda
void
main(int argc, char **argv)
{
	uchar buf[4], *rec;
	long start = 0;

	ARGBEGIN{
	case 'H':		/* print no Handler Link support */
		Hflag = 0x01;
		break;
	case '0':		/* show dev's supported by Site40 */
		devices |= 0x02;
		break;
	case '8':		/* show dev's supported by Site48 */
		devices |= 0x04;
		break;
	case 'U':		/* show dev's supported by USM-340 */
		devices |= 0x08;
		break;
	case 'C':		/* show dev's supported by ChipSite */
		devices |= 0x10;
		break;
	case 'P':		/* show dev's supported by PinSite */
		devices |= 0x20;
		break;
	case 'S':		/* show dev's supported by SetSite */
		devices |= 0x80;
		break;
	case 's':		/* don't print support field */
		sflag++;
		break;
	case 'r':		/* dump record at this address */
		start = strtol(ARGF(), 0, 0);
		break;
	case 'A':		/* print alg addresses on fd 2 */
		out2 = malloc(sizeof(Biobuf));
		Binit(out2, 2, OWRITE);
		/* fall through */
	case 'D':
		++debug;
		break;
	}ARGEND

	if(devices == 0)
		devices = 0xff;

	if(argc > 0){
		in = open(argv[0], OREAD);
		if(in < 0){
			perror(argv[0]);
			exits("open");
		}
	}else
		in = 0;
	out = malloc(sizeof(Biobuf));
	Binit(out, 1, OWRITE);

	if(debug){
		Read(buf, 0, 4);
		hout(buf, 4);
		Bprint(out, "\n");
	}
	if(start > 0){
		rec = getrec(start);
		dorec(rec, dumpit, start==4 ? 6 : 18);
	}else{
		rec = getrec(4);
		dorec(rec, domanu, 6);
	}
	free(rec);

	exits(0);
}