Lines Matching +full:p +full:- +full:256
2 * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
39 * All encoding functions take a pointer `p' to first position in
42 * the number of characters written in `size' (if non-NULL).
47 der_put_unsigned (unsigned char *p, size_t len, const unsigned *v, size_t *size)
49 unsigned char *base = p;
54 *p-- = val % 256;
55 val /= 256;
56 --len;
61 if(p[1] >= 128) {
64 *p-- = 0;
66 *size = base - p;
72 *p = 0;
79 der_put_unsigned64 (unsigned char *p, size_t len, const uint64_t *v, size_t *size)
81 unsigned char *base = p;
86 *p-- = val % 256;
87 val /= 256;
88 --len;
93 if(p[1] >= 128) {
96 *p-- = 0;
98 *size = base - p;
104 *p = 0;
111 der_put_integer (unsigned char *p, size_t len, const int *v, size_t *size)
113 unsigned char *base = p;
120 *p-- = val % 256;
121 len--;
122 val /= 256;
124 if(p[1] >= 128) {
127 *p-- = 0;
128 len--;
135 *p-- = ~(val % 256);
136 len--;
137 val /= 256;
139 if(p[1] < 128) {
142 *p-- = 0xff;
143 len--;
146 *size = base - p;
151 der_put_integer64 (unsigned char *p, size_t len, const int64_t *v, size_t *size)
153 unsigned char *base = p;
160 *p-- = val % 256;
161 len--;
162 val /= 256;
164 if(p[1] >= 128) {
167 *p-- = 0;
168 len--;
175 *p-- = ~(val % 256);
176 len--;
177 val /= 256;
179 if(p[1] < 128) {
182 *p-- = 0xff;
183 len--;
186 *size = base - p;
192 der_put_length (unsigned char *p, size_t len, size_t val, size_t *size)
198 *p = val;
206 *p-- = val % 256;
207 val /= 256;
208 len--;
211 *p = 0x80 | l;
219 der_put_boolean(unsigned char *p, size_t len, const int *data, size_t *size)
224 *p = 0xff;
226 *p = 0;
232 der_put_general_string (unsigned char *p, size_t len,
239 p -= slen;
240 memcpy (p+1, *str, slen);
246 der_put_utf8string (unsigned char *p, size_t len,
249 return der_put_general_string(p, len, str, size);
253 der_put_printable_string (unsigned char *p, size_t len,
256 return der_put_octet_string(p, len, str, size);
260 der_put_ia5_string (unsigned char *p, size_t len,
263 return der_put_octet_string(p, len, str, size);
267 der_put_bmp_string (unsigned char *p, size_t len,
271 if (len / 2 < data->length)
273 p -= data->length * 2;
274 for (i = 0; i < data->length; i++) {
275 p[1] = (data->data[i] >> 8) & 0xff;
276 p[2] = data->data[i] & 0xff;
277 p += 2;
279 if (size) *size = data->length * 2;
284 der_put_universal_string (unsigned char *p, size_t len,
288 if (len / 4 < data->length)
290 p -= data->length * 4;
291 for (i = 0; i < data->length; i++) {
292 p[1] = (data->data[i] >> 24) & 0xff;
293 p[2] = (data->data[i] >> 16) & 0xff;
294 p[3] = (data->data[i] >> 8) & 0xff;
295 p[4] = data->data[i] & 0xff;
296 p += 4;
298 if (size) *size = data->length * 4;
303 der_put_visible_string (unsigned char *p, size_t len,
306 return der_put_general_string(p, len, str, size);
310 der_put_octet_string (unsigned char *p, size_t len,
313 if (len < data->length)
315 p -= data->length;
316 memcpy (p+1, data->data, data->length);
317 *size = data->length;
322 der_put_heim_integer (unsigned char *p, size_t len,
325 unsigned char *buf = data->data;
328 if (data->length == 0) {
331 *p-- = 0;
336 if (len < data->length)
339 len -= data->length;
341 if (data->negative) {
343 for (i = data->length - 1, carry = 1; i >= 0; i--) {
344 *p = buf[i] ^ 0xff;
346 carry = !++*p;
347 p--;
349 if (p[1] < 128) {
352 *p-- = 0xff;
353 len--;
357 p -= data->length;
358 memcpy(p + 1, buf, data->length);
360 if (p[1] >= 128) {
363 p[0] = 0;
364 len--;
369 *size = data->length + hibitset;
374 der_put_generalized_time (unsigned char *p, size_t len,
384 e = der_put_octet_string(p, len, &k, &l);
394 der_put_utctime (unsigned char *p, size_t len,
404 e = der_put_octet_string(p, len, &k, &l);
414 der_put_oid (unsigned char *p, size_t len,
417 unsigned char *base = p;
420 for (n = data->length - 1; n >= 2; --n) {
421 unsigned u = data->components[n];
425 *p-- = u % 128;
427 --len;
431 *p-- = 128 + u % 128;
433 --len;
438 *p-- = 40 * data->components[0] + data->components[1];
439 *size = base - p;
444 der_put_tag (unsigned char *p, size_t len, Der_class class, Der_type type,
450 *p = MAKE_TAG(class, type, tag);
459 *p-- = tag % 128 | continuation;
460 len--;
467 *p-- = MAKE_TAG(class, type, 0x1f);
475 der_put_length_and_tag (unsigned char *p, size_t len, size_t len_val,
483 e = der_put_length (p, len, len_val, &l);
486 p -= l;
487 len -= l;
489 e = der_put_tag (p, len, class, type, tag, &l);
504 s->data = malloc(len + 1);
505 if (s->data == NULL)
507 s->length = len;
511 snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
515 snprintf (s->data, len + 1, "%02d%02d%02d%02d%02d%02dZ",
523 der_put_bit_string (unsigned char *p, size_t len,
526 size_t data_size = (data->length + 7) / 8;
529 p -= data_size + 1;
531 memcpy (p+2, data->data, data_size);
532 if (data->length && (data->length % 8) != 0)
533 p[1] = 8 - (data->length % 8);
535 p[1] = 0;
546 ret = memcmp(s1->data, s2->data,
547 s1->length < s2->length ? s1->length : s2->length);
550 return s1->length - s2->length;