提交 ec7c9ee8 编写于 作者: D Dr. Stephen Henson

Indent some of the code examples.

上级 f82bb9cb
...@@ -646,26 +646,26 @@ built OpenSSL with /MD your application must use /MD and cannot use /MDd. ...@@ -646,26 +646,26 @@ built OpenSSL with /MD your application must use /MD and cannot use /MDd.
* How do I read or write a DER encoded buffer using the ASN1 functions? * How do I read or write a DER encoded buffer using the ASN1 functions?
You have two options. You can either use a memory BIO in conjunction You have two options. You can either use a memory BIO in conjunction
with the i2d_XXX_bio() or d2i_XXX_bio() functions or you can use the with the i2d_*_bio() or d2i_*_bio() functions or you can use the
i2d_XXX(), d2i_XXX() functions directly. Since these are often the i2d_*(), d2i_*() functions directly. Since these are often the
cause of grief here are some code fragments using PKCS7 as an example: cause of grief here are some code fragments using PKCS7 as an example:
unsigned char *buf, *p; unsigned char *buf, *p;
int len; int len;
len = i2d_PKCS7(p7, NULL); len = i2d_PKCS7(p7, NULL);
buf = OPENSSL_malloc(len); /* or Malloc, error checking omitted */ buf = OPENSSL_malloc(len); /* or Malloc, error checking omitted */
p = buf; p = buf;
i2d_PKCS7(p7, &p); i2d_PKCS7(p7, &p);
At this point buf contains the len bytes of the DER encoding of At this point buf contains the len bytes of the DER encoding of
p7. p7.
The opposite assumes we already have len bytes in buf: The opposite assumes we already have len bytes in buf:
unsigned char *p; unsigned char *p;
p = buf; p = buf;
p7 = d2i_PKCS7(NULL, &p, len); p7 = d2i_PKCS7(NULL, &p, len);
At this point p7 contains a valid PKCS7 structure of NULL if an error At this point p7 contains a valid PKCS7 structure of NULL if an error
occurred. If an error occurred ERR_print_errors(bio) should give more occurred. If an error occurred ERR_print_errors(bio) should give more
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册