| plan 9 kernel history: overview | file list | diff list |
2001/0825/port/devssl.c (diff list | history)
| 2001/0823/sys/src/9/port/devssl.c:415,421 – 2001/0825/sys/src/9/port/devssl.c:415,421 (short | long | prev | next) | ||
| 1996/1029 | while(sofar < n){ | |
| 1997/0327 | bl = devtab[s->c->type]->bread(s->c, Maxdmsg, 0); | |
| 1996/1029 | if(bl == 0) | |
| 2001/0825 | nexterror(); | |
| 1996/1029 | *l = bl; i = 0; for(b = bl; b; b = b->next){ | |
| 2001/0823/sys/src/9/port/devssl.c:457,463 – 2001/0825/sys/src/9/port/devssl.c:457,462 | ||
| 1996/1029 | /* | |
| 2000/0913 | * give back n bytes | |
| 2001/0823/sys/src/9/port/devssl.c:477,482 – 2001/0825/sys/src/9/port/devssl.c:476,482 | ||
| 2000/0914 | memmove(b->rp, p, n); | |
| 2000/0913 | } } | |
| 2001/0825 | */ | |
| 2000/0913 | /* | |
| 1996/1029 | * remove at most n bytes from the queue, if discard is set | |
| 2001/0823/sys/src/9/port/devssl.c:538,545 – 2001/0825/sys/src/9/port/devssl.c:538,545 | ||
| 1995/1213 | { | |
| 1996/0531 | volatile struct { Dstate *s; } s; | |
| 1995/1218 | Block *b; | |
| 2000/0913 |
| |
| 2001/0825 | uchar consumed[3], *p; int toconsume; | |
| 1996/1029 | int len, pad; | |
| 1995/1217 | ||
| 1996/1029 | s.s = dstate[CONV(c->qid)]; | |
| 2001/0823/sys/src/9/port/devssl.c:548,592 – 2001/0825/sys/src/9/port/devssl.c:548,606 | ||
| 1996/1029 | if(s.s->state == Sincomplete) | |
| 1995/1217 | error(Ebadusefd); | |
| 2000/0913 |
| |
| 2001/0825 | qlock(&s.s->in.q); | |
| 1995/1217 | if(waserror()){ | |
| 2001/0527 |
| |
| 2000/0913 |
| |
| 1996/0531 | qunlock(&s.s->in.q); | |
| 1995/1217 | nexterror(); | |
| 1995/1213 | } | |
| 1996/0531 |
| |
| 1995/1217 | ||
| 1996/1029 | if(s.s->processed == 0){ | |
| 1995/1217 |
| |
| 1996/1029 |
| |
| 2000/0913 |
| |
| 2001/0825 | /* * Read in the whole message. Until we've got it all, * it stays on s.s->unprocessed, so that if we get Eintr, * we'll pick up where we left off. */ ensure(s.s, &s.s->unprocessed, 3); s.s->unprocessed = pullupblock(s.s->unprocessed, 2); p = s.s->unprocessed->rp; if(p[0] & 0x80){ len = ((p[0] & 0x7f)<<8) | p[1]; | |
| 1996/1029 | ensure(s.s, &s.s->unprocessed, len); | |
| 1995/1217 | pad = 0; | |
| 2001/0825 | toconsume = 2; | |
| 1995/1217 | } else { | |
| 2000/0913 |
| |
| 1996/1029 |
| |
| 2000/0913 |
| |
| 2001/0825 | len = ((p[0] & 0x3f)<<8) | p[1]; pad = p[2]; | |
| 1996/1029 | if(pad > len){ print("pad %d buf len %d\n", pad, len); error("bad pad in ssl message"); } | |
| 2001/0825 | toconsume = 3; | |
| 1995/1217 | } | |
| 2000/0913 |
| |
| 2001/0825 | ensure(s.s, &s.s->unprocessed, toconsume+len+pad); | |
| 1995/1217 | ||
| 2000/0919 |
| |
| 2000/0913 |
| |
| 2001/0825 | /* * Now we have a full SSL packet in the unprocessed list. * Start processing. We can't get Eintr's here. * The only cause for errors from here until the end of the * loop is allocation failures in the block manipulation. * We'll worry about that when we come across it. | |
| 2000/0913 | */ | |
| 1995/1217 | ||
| 2001/0825 | if(waserror()){ print("devssl: unhandled allocation failure\n"); nexterror(); } /* skip header */ consume(&s.s->unprocessed, consumed, toconsume); | |
| 2000/0913 | /* grab the next message and decode/decrypt it */ | |
| 2001/0602 |
| |
| 2001/0825 | b = qtake(&s.s->unprocessed, len+pad, 0); | |
| 2000/0913 | ||
| 2001/0825 | if(blocklen(b) != len+pad) print("devssl: sslbread got wrong count %d != %d", blocklen(b), len); | |
| 1996/1029 | if(waserror()){ qunlock(&s.s->in.ctlq); | |
| 2000/0913 | if(b != nil) | |
| 2001/0823/sys/src/9/port/devssl.c:596,607 – 2001/0825/sys/src/9/port/devssl.c:610,623 | ||
| 1996/1029 | qlock(&s.s->in.ctlq); switch(s.s->state){ case Sencrypting: | |
| 2001/0825 | if(b == nil) error("ssl message too short (encrypting)"); | |
| 2000/0913 | b = decryptb(s.s, b); | |
| 1996/1029 | break; case Sdigesting: | |
| 2000/0913 | b = pullupblock(b, s.s->diglen); if(b == nil) | |
| 1996/1029 |
| |
| 2001/0825 | error("ssl message too short (digesting)"); | |
| 2000/0913 | checkdigestb(s.s, b); b->rp += s.s->diglen; | |
| 1996/1029 | break; | |
| 2001/0823/sys/src/9/port/devssl.c:609,615 – 2001/0825/sys/src/9/port/devssl.c:625,631 | ||
| 2000/0913 | b = decryptb(s.s, b); b = pullupblock(b, s.s->diglen); if(b == nil) | |
| 1997/0618 |
| |
| 2001/0825 | error("ssl message too short (dig+enc)"); | |
| 2000/0913 | checkdigestb(s.s, b); b->rp += s.s->diglen; | |
| 1998/0501 | len -= s.s->diglen; | |
| 2001/0823/sys/src/9/port/devssl.c:625,631 – 2001/0825/sys/src/9/port/devssl.c:641,647 | ||
| 2000/0913 | s.s->in.mid++; qunlock(&s.s->in.ctlq); poperror(); | |
| 2001/0825 | poperror(); | |
| 1995/1217 | } | |
| 1996/1029 | /* return at most what was asked for */ | |