{"id":791,"date":"2009-12-01T20:26:44","date_gmt":"2009-12-01T20:26:44","guid":{"rendered":"http:\/\/pchero21.com\/?p=791"},"modified":"2009-12-01T20:26:44","modified_gmt":"2009-12-01T20:26:44","slug":"openssl-%eb%8d%b0%ec%9d%b4%ed%84%b0-%ec%95%94%ed%98%b8%ed%99%94","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=791","title":{"rendered":"OpenSSL &#8211; \ub370\uc774\ud130 \uc554\ud638\ud654"},"content":{"rendered":"<p><P><br \/>\n<BLOCKQUOTE><br \/>\n<P>#include &lt;stdio.h&gt;<br \/>#include &lt;string.h&gt;<br \/>#include &lt;openssl\/bio.h&gt;<br \/>#include &lt;openssl\/err.h&gt;<br \/>#include &lt;openssl\/bn.h&gt;<br \/>#include &lt;openssl\/dh.h&gt;<br \/>#include &lt;openssl\/rand.h&gt;<br \/>#include &lt;openssl\/pem.h&gt;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>#define IN_FILE &#8220;.\/plain.txt&#8221; &nbsp; \/\/ plain file<br \/>#define OUT_FILE &#8220;.\/encrypt.txt&#8221; &nbsp; &nbsp; &nbsp;&nbsp; \/\/ cipher file<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>unsigned char* readFile(char *file, int *readLen);<br \/>unsigned char *readFileBio(BIO *fileBIO, int *readLen);<br \/>unsigned char *addString(unsigned char *destString, int destLen, const unsigned char *addString, int addLen);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>int main(int argc, char* argv[])<br \/>{<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud0a4\uc640 IV\uac12\uc740 \ud3b8\uc758\ub97c \uc704\ud574 \uc9c1\uc811 \ub9cc\ub4e0\ub2e4.<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char key[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char iv[] = {1, 2, 3, 4, 5, 6, 7, 8};<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; int len;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char *readBuffer, *outbuf; <br \/>&nbsp; &nbsp; &nbsp; &nbsp; int outlen, tmplen;<\/P><br \/>\n<P><br \/>&nbsp; &nbsp; &nbsp; &nbsp; BIO *errBIO = NULL;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; BIO *outBIO = NULL;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc5d0\ub7ec \ubc1c\uc0dd\uc758 \uacbd\uc6b0 \ud574\ub2f9 \uc5d0\ub7ec \uc2a4\ud2b8\ub9c1 \ucd9c\ub825\uc744 \uc704\ud574 \ubbf8\ub9ac \uc5d0\ub7ec \uc2a4\ud2b8\ub9c1\ub4e4\uc744 \ub85c\ub529.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; ERR_load_crypto_strings();<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud45c\uc900 \ud654\uba74 \ucd9c\ub825 BIO \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if((errBIO = BIO_new(BIO_s_file())) != NULL)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BIO_set_fp(errBIO, stderr, BIO_NOCLOSE|BIO_FP_TEXT);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c \ucd9c\ub825 BIO \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; outBIO = BIO_new_file(OUT_FILE, &#8220;wb&#8221;);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if(!outBIO) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BIO_printf(errBIO, &#8220;Can not create file [%s]!&#8221;, OUT_FILE);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERR_print_errors(errBIO);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c\uc5d0\uc11c \ub370\uc774\ud130 \uc77d\uc5b4\uc624\uae30<br \/>&nbsp; &nbsp; &nbsp; &nbsp; readBuffer = readFile(IN_FILE, &amp;len);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc554\ud638\ud654 \ucee8\ud14d\uc2a4\ud2b8 EVP_CIPHER_CTX \uc0dd\uc131, \ucd08\uae30\ud654<br \/>&nbsp; &nbsp; &nbsp; &nbsp; EVP_CIPHER_CTX ctx;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; EVP_CIPHER_CTX_init(&amp;ctx);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ucd08\uae30\ud654<br \/>&nbsp; &nbsp; &nbsp; &nbsp; EVP_EncryptInit_ex(&amp;ctx, EVP_bf_cbc(), NULL, key, iv);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ucd08\uae30\ud654\uac00 \ub05d\ub09c\ud6c4\uc5d0 \ud574\uc57c \ud55c\ub2e4. \uc554\ud638\ubb38 \uc800\uc7a5\ud560 \ubc84\ud37c \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; outbuf = (unsigned char*)malloc(sizeof(unsigned char) * (len + EVP_CIPHER_CTX_block_size(&amp;ctx)));<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc5c5\ub370\uc774\ud2b8. \ub9c8\uc9c0\ub9c9 \ube14\ub85d\uc744 \uc81c\uc678\ud558\uace0 \ubaa8\ub450 \uc554\ud638\ud654.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if(!EVP_EncryptUpdate(&amp;ctx, outbuf, &amp;outlen, readBuffer, strlen((char *)readBuffer))) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc885\ub8cc. \ub9c8\uc9c0\ub9c9 \ube14\ub85d\uc744 \uc554\ud638\ud654<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if(!EVP_EncryptFinal_ex(&amp;ctx, outbuf + outlen, &amp;tmplen)) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc554\ud638\ubb38 \uae38\uc774\ub294 \uc5c5\ub370\uc774\ud2b8. \uc885\ub8cc \uacfc\uc815\uc5d0\uc11c \ub098\uc628 \uacb0\uacfc\uc758 \ud569<br \/>&nbsp; &nbsp; &nbsp; &nbsp; outlen += tmplen;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; EVP_CIPHER_CTX_cleanup(&amp;ctx);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; BIO_printf(errBIO, &#8220;Create Cipher Complete.nSaving [%s] filen&#8221;, OUT_FILE);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c\uc5d0 \uac19\uc740 \ub0b4\uc6a9\uc744 \ucd9c\ub825\ud55c\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; BIO_write(outBIO, outbuf, outlen);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uac1d\uccb4 \uc81c\uac70<br \/>&nbsp; &nbsp; &nbsp; &nbsp; BIO_free(outBIO);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br \/>}<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>unsigned char* readFile(char *file, int *readLen)<br \/>{<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char *retBuffer = NULL;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char *buffer = NULL;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int length = 0;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c BIO \uc815\uc758<br \/>&nbsp; &nbsp; &nbsp; &nbsp; BIO *fileBIO = NULL;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc778\uc790\ub85c \ub118\uc5b4\uc628 \ud30c\uc77c\uc744 \uc5f4\uace0, \ud30c\uc77c BIO \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; fileBIO = BIO_new_file(file, &#8220;rb&#8221;);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if(!fileBIO) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;file open(%s) error!n&#8221;, file);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc784\uc2dc\ub85c 1000 \ubc14\uc774\ud2b8 \ub9cc\ud07c\uc758 \uc77d\uc740 \ub370\uc774\ud130\ub97c \uc800\uc7a5\ud560 \ubc84\ud37c \uc0dd\uc131.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; buffer = (unsigned char*)malloc(1001);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; *readLen = 0;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; while(1) {<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c BIO\uc5d0\uc11c 1000 \ubc14\uc774\ud2b8 \ub9cc\ud07c \uc77d\uc5b4\uc11c buffer\uc5d0 \uc800\uc7a5 \ud55c\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = BIO_read(fileBIO, buffer, 1000);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc548\uc804\uc744 \uc704\ud574 \ubc84\ud37c\uc758 \ub05d\uc740 NULL\ub85c \ucc44\uc6b4\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buffer[length] = 0;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc784\uc2dc\ub85c \uc77d\uc740 1000 \ubc14\uc774\ud2b8\uc758 \ub370\uc774\ud130\ub97c \ub9ac\ud134 \ubc84\ud37c\uc5d0 \ub354\ud55c\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retBuffer = addString(retBuffer, *readLen, buffer, length);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc9c0\uae08\uae4c\uc9c0 \uc77d\uc740 \ub370\uc774\ud130\uc758 \uae38\uc774\ub97c \ub354\ud55c\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *readLen = *readLen + length;<br \/><\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub9cc\uc57d \uc9c0\uae08 \ud30c\uc77c\uc5d0\uc11c \uc77d\uc740 \ub370\uc774\ud130\uc758 \uae38\uc774\uac00 \uaf2d 1000 \ubc14\uc774\ud2b8\ub77c\uba74 \uc55e\uc73c\ub85c \ub354 \uc77d\uc744<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub370\uc774\ud130\uac00 \uc788\uc744 \uac83\uc774\ub2e4. \ud558\uc9c0\ub9cc 1000 \ubc14\uc774\ud2b8\ubcf4\ub2e4 \uc791\ub2e4\uba74 \ub354 \uc774\uc0c1 \uc77d\uc744 \ub370\uc774\ud130\uac00<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc5c6\uc744 \uac83\uc774\ubbc0\ub85c \uc885\ub8cc\ud55c\ub2e4.<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(length == 1000)<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ud30c\uc77c \ud3ec\uc778\ud130\ub97c 1000 \ubc14\uc774\ud2b8 \ub4a4\ub85c \uc62e\uae34\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BIO_seek(fileBIO, 1000);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uac1d\uccb4 \uc0ad\uc81c<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; BIO_free(fileBIO);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; free(buffer);<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; return retBuffer;<br \/>}<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><br \/>unsigned char* addString(unsigned char* destString, int destLen, const unsigned char *addString, int addLen)<br \/>{<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub9ac\ud134\ud560 \ubc84\ud37c \uc815\uc758<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char *retString;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int i;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub9cc\uc57d \ub367\ubd99\uc77c \ub300\uc0c1 \ubc84\ud37c\uac00 NULL, \uc774\uac70\ub098 \uae38\uc774\uac00 0\uc774\uba74 \ub367\ubd99\uc77c \ub300\uc0c1\ubc84\ud37c\uac00 \uc5c6\ub294 \uacbd\uc6b0<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc774\ubbc0\ub85c \uc0c8\ub85c \uc0dd\uc131\ud558\uace0, \ub367\ubd99\uc77c \ubc84\ud37c\uc758 \ub0b4\uc6a9\uc744 \ubcf5\uc0ac \ud55c\ub2e4.<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; if((destString == NULL) || (destLen == 0)) {<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub367\ubd99\uc77c \ubc84\ud37c \uae38\uc774 \ub9cc\ud07c\uc758 \ubc84\ud37c \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString = (unsigned char*)malloc(sizeof(unsigned char) * (addLen + 1));<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub367\ubd99\uc77c \ubc84\ud37c\uc758 \ub0b4\uc6a9\uc744 \uc0c8\ub85c\uc6b4 \ubc84\ud37c\uc5d0 \ubcf5\uc0ac<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; addLen; i++) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString[i] = addString[i];<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc548\uc804\uc744 \uc704\ud574 \ubc84\ud37c\uc758 \ub9c8\uc9c0\ub9c9\uc5d0 NULL \ubc14\uc774\ud2b8\ub97c \ubb4d\uc778\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString[i] = NULL;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub367\ubd99\uc77c \ub300\uc0c1 \ubc84\ud37c\uac00 \uc788\ub294 \uacbd\uc6b0\uc774\ubbc0\ub85c \ub367\ubd99\uc77c \ub300\uc0c1 \ubc84\ud37c\uc758 \uae38\uc774\ub97c<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub354\ud55c \ub9cc\ud07c\uc758 \ubc84\ud37c\ub97c \uc0c8\ub85c \uc0dd\uc131\ud558\uace0, \ub450 \ubc84\ud37c\uc758 \ub0b4\uc6a9\uc744 \uc0c8\ub85c\uc6b4 \ubc84\ud37c\uc5d0 \ubcf5\uc0ac\ud55c\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; else {<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub300\uc0c1 \ubc84\ud37c\uc758 \uae38\uc774\uc640 \ub367\ubd99\uc77c \uae38\uc774\ub97c \ub354\ud55c \ub9cc\ud07c\uc758 \ubc84\ud37c \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString = (unsigned char*)malloc(sizeof(unsigned char) * (destLen + addLen + 1));<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub367\ubd99\uc77c \ub300\uc0c1 \ubc84\ud37c \ub0b4\uc6a9\uc744 \uc0c8\ub85c\uc6b4 \ubc84\ud37c\uc5d0 \ubcf5\uc0ac<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; destLen; i++) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString[i] = destString[i];<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub367\ubd99\uc77c \ubc84\ud37c\uc758 \ub0b4\uc6a9\uc744 \uc0c8\ub85c\uc6b4 \ubc84\ud37c\uc5d0 \ubcf5\uc0ac<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; addLen; i++) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString[i + destLen] = addString[i];<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc548\uc804\uc744 \uc704\ud574 \ubc84\ud37c\uc758 \ub9c8\uc9c0\ub9c9\uc5d0 NULL \ubc14\uc774\ud2b8\ub97c \ubd99\uc778\ub2e4.<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retString[i + destLen] = NULL;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uba54\ubaa8\ub9ac\uc5d0\uc11c \uc0ad\uc81c<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; free(destString);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; return retString;<br \/>}<\/P><\/BLOCKQUOTE><br \/><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt;#include &lt;string.h&gt;#include &lt;openssl\/bio.h&gt;#include &lt;openssl\/err.h&gt;#include &lt;openssl\/bn.h&gt;#include &lt;openssl\/dh.h&gt;#include &lt;openssl\/rand.h&gt;#include &lt;openssl\/pem.h&gt; &nbsp; #define IN_FILE &#8220;.\/plain.txt&#8221; &nbsp; \/\/ plain file#define OUT_FILE &#8220;.\/encrypt.txt&#8221; &nbsp; &nbsp; &nbsp;&nbsp; \/\/ cipher file &nbsp; unsigned char* readFile(char *file, int *readLen);unsigned char *readFileBio(BIO *fileBIO, int *readLen);unsigned char *addString(unsigned char &hellip; <a href=\"http:\/\/pchero21.com\/?p=791\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[53],"tags":[297,362,364],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/791"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=791"}],"version-history":[{"count":0,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/791\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=791"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}