Пример #1
0
static bool
prepare_pem_contents (p11_enumerate *ex,
                      p11_buffer *buffer)
{
	char message[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
	unsigned char *der;
	node_asn *asn;
	size_t offset;
	int ret;
	int len;

	p11_buffer_add (buffer, ex->cert_der, ex->cert_len);

	asn = p11_asn1_create (ex->asn1_defs, "OPENSSL.CertAux");
	return_val_if_fail (asn != NULL, false);

	if (!write_trust_and_rejects (ex, asn) ||
	    !write_alias (ex, asn) ||
	    !write_keyid (ex, asn) ||
	    !write_other (ex, asn))
		return_val_if_reached (false);

	len = 0;
	offset = buffer->len;

	ret = asn1_der_coding (asn, "", NULL, &len, message);
	return_val_if_fail (ret == ASN1_MEM_ERROR, false);

	der = p11_buffer_append (buffer, len);
	return_val_if_fail (der != NULL, false);

	ret = asn1_der_coding (asn, "", der, &len, message);
	return_val_if_fail (ret == ASN1_SUCCESS, false);

	buffer->len = offset + len;
	asn1_delete_structure (&asn);
	return true;
}
Пример #2
0
void DoWrite(unsigned char *s)
{
   int x,y;
   unsigned char *p;
   int newline=0;

   x=(crtX-1)*8;
   y=(crtY-1)*14;

   if (memcmp(s,"\x03\x08 \x08",4)==0) {
      XFillRectangle(dpy, pm, gcclear, x-8,y,8,14);
      crtX--;
      return;
   }

   XFillRectangle(dpy, pm, gcclear, x,y,8*s[0],14);

   p=s+1;
   while (p<=s+s[0]) {
      switch (*p) {
         case 10:
             newline=1;
             if (p!=s+s[0]) fprintf(stderr,"NOT IMPLEMENTED: newline in middle of string");
             s[0]--;
             break;
         case 248: *p=176; break; /* degree */
         case 230: *p=181; break; /* mu */
         default: if (*p<32 || *p>127) { write_other(x+8*(p-s-1), y, *p); *p=' '; }
      }
      p++;
   }

   XDrawString(dpy,pm,gctext,x,y+fontyoffs,s+1,s[0]);
   crtX+=s[0];
   if (newline) { crtX=crtXmin; crtY++; }

   drawcounter++;
}