{"id":2423,"date":"2018-01-27T20:00:55","date_gmt":"2018-01-27T11:00:55","guid":{"rendered":"http:\/\/haisins.epac.to\/wordpress\/?p=2423"},"modified":"2021-10-29T22:59:51","modified_gmt":"2021-10-29T13:59:51","slug":"db-security-%ea%b3%b5%ec%a7%9c%eb%a1%9c-db-%ec%95%94%ed%98%b8%ed%99%94-%ed%95%98%eb%8a%94-%eb%b0%a9%eb%b2%95","status":"publish","type":"post","link":"http:\/\/haisins.synology.me\/wordpress\/?p=2423","title":{"rendered":"[DB Security] \uacf5\uc9dc\ub85c DB \uc554\ud638\ud654 \ud558\ub294 \ubc29\ubc95"},"content":{"rendered":"<p>\ud0c0 \uc0ac\uc774\ud2b8\uc5d0\uc11c \uc0ac\uc6a9 \ud588\ub358 \uc624\ub77c\ud074 DB\uc758 \uae30\ubcf8 \uc81c\uacf5 \uc554\ud638\ud654 \ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c<\/p>\n<p><span style=\"color: #ff0000;\">\ucd94\uac00 \uc554\ud638\ud654 \uc194\ub8e8\uc158 \uad6c\ub9e4 \uc5c6\uc774 \uac1c\uc778\uc815\ubcf4 \ub370\uc774\ud130 \ub97c\u00a0 \uceec\ub7fc \ub2e8\uc704 \uc554\ud638\ud654 \ud558\ub294\u00a0 \ubc29\ubc95 \uc785\ub2c8\ub2e4.<\/span><\/p>\n<p><strong><span style=\"font-size: large;\">\uc591\ubc29\ud5a5 \uc554\ud638\ud654<\/span> <\/strong><\/p>\n<p>&lt; \uc694\uc57d &gt;<\/p>\n<p>\uc544\ub798 \ubc29\uc2dd\uc73c\ub85c \ud0a4 \ud14c\uc774\ube14\uacfc \uc554\ud638\ud654 \/ \ubcf5\ud638\ud654 \ud568\uc218\ub97c \ub9cc\ub4e0 \ub2e4\uc74c \uac1c\uc778\uc815\ubcf4 \ub370\uc774\ud130\ub97c<\/p>\n<p>\uc785\ub825 , \uc218\uc815 , \uc870\ud68c \ud558\ub294 \ubd80\ubd84\uc744 \ubaa8\ub450 \ubcc0\uacbd ( SQL , SP , java \ub4f1\ub4f1 ) \ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<p>&nbsp;<\/p>\n<p>&lt; \ubc29\uc2dd\uc124\uba85 &gt;<\/p>\n<p>1.\u00a0\u00a0\u00a0 Key \ud14c\uc774\ube14\uc744 \uc77c\ub2e8 \ub9cc\ub4e4\uace0 key \ub370\uc774\ud130\ub97c \ud55c\uac74 \ub123\uc2b5\ub2c8\ub2e4. ( \uc784\uc758\ub85c )<\/p>\n<p>2.\u00a0\u00a0\u00a0 Encode param \ud568\uc218 \uc640 decode param \ud568\uc218\ud30c\uc77c\uc744 \ubcf4\uba74 \uc624\ub77c\ud074\uc758 \uae30\ubcf8 \ud568\uc218\ub97c \uc774\uc6a9\ud569\ub2c8\ub2e4.<\/p>\n<p>3.\u00a0\u00a0\u00a0 Encode param \ud568\uc218\ub294 \uc554\ud638\ud654 \ud560 \uceec\ub7fc \ub370\uc774\ud130\ub97c \uc785\ub825 \ub610\ub294 \uc218\uc815\ud558\ub294 \ucffc\ub9ac\uc5d0 \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<\/p>\n<p>4.\u00a0\u00a0\u00a0 Decode param \ud568\uc218\ub294 \uc554\ud638\ud654 \ud55c \uceec\ub7fc \ub370\uc774\ud130\ub97c \uc870\ud68c \ud558\ub294\ub370 \uc0ac\uc6a9 \ud558\ub294 \ucffc\ub9ac\uc5d0 \uc0ac\uc6a9 \ud569\ub2c8\ub2e4.<\/p>\n<p>&nbsp;<\/p>\n<p>&lt; \uc8fc\uc758 &gt;<\/p>\n<p>\ub9cc\uc57d \uc0ac\ub0b4 \ubcf4\uc548 \uaddc\uce59\uc0c1 \ud0a4 \ud14c\uc774\ube14\uc744 \uac19\uc740 \uba38\uc2e0\uc5d0 \ub193\uc73c\uba74 \uc548\ub418\ub294 \uacbd\uc6b0 \ub514\ube44\ub9c1\ud06c\ub97c \uc368\uc11c \ub2e4\ub978 DB\uc5d0 \ub123\uace0 \uc870\ud68c \ud558\uac8c \ub429\ub2c8\ub2e4.<br \/>\n(\uc8fc\uc758 : \ud2b8\ub798\ud53d\uc774 \ubab0\ub9b4\uacbd\uc6b0 \uc131\ub2a5 \ubcf4\uc7a5\uc774 \uc548\ub429\ub2c8\ub2e4. )<\/p>\n<p>&nbsp;<\/p>\n<p>1. Key \ud14c\uc774\ube14 \uc0dd\uc131 \ubc0f Key Data Insert<\/p>\n<p>CREATE TABLE SY_SECURE_KEY<br \/>\n(<br \/>\nKEY\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LONG RAW<br \/>\n)<br \/>\nTABLESPACE USERS<br \/>\nPCTFREE 10<br \/>\nPCTUSED 0<br \/>\nINITRANS 1<br \/>\nMAXTRANS 255<br \/>\nSTORAGE<br \/>\n(<br \/>\nINITIAL 65536<br \/>\nMINEXTENTS 1<br \/>\nMAXEXTENTS UNLIMITED<br \/>\nBUFFER_POOL DEFAULT<br \/>\n)<br \/>\nLOGGING ;<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO SY_SECURE_KEY VALUES (\u20184E5065664D73337546314\u2026\u2026\u2026..0000 <span style=\"color: #ff0000;\">\uc784\uc758 \ud0a4\uac12 \uc785\ub825 <\/span>\u2019) ;<\/p>\n<p>&nbsp;<\/p>\n<p>2. \uc554\ud638\ud654 \ud568\uc218 \uc0dd\uc131<\/p>\n<p>CREATE OR REPLACE function encodeParam<br \/>\n(<br \/>\np_in\u00a0\u00a0\u00a0 in varchar2<br \/>\n)<br \/>\nreturn varchar2 is<br \/>\nl_return_val varchar2(2048) ;<br \/>\nl_enc_val raw (2048);<br \/>\nl_mod\u00a0\u00a0\u00a0\u00a0 number := DBMS_CRYPTO.ENCRYPT_AES256<br \/>\n+ DBMS_CRYPTO.CHAIN_ECB<br \/>\n+ DBMS_CRYPTO.PAD_PKCS5;<br \/>\np_key raw (65) ;<br \/>\nbegin<\/p>\n<p>if p_in is not null and (isEncoded(p_in)=0) then<\/p>\n<p>select key into p_key from sy_secure_key ;<\/p>\n<p>l_enc_val := DBMS_CRYPTO.encrypt( UTL_RAW.cast_to_raw(p_in), l_mod, p_key );<br \/>\nl_return_val := UTL_RAW.cast_to_varchar2( utl_encode.base64_encode(l_enc_val) ) ;<\/p>\n<p>else<br \/>\nl_return_val := p_in ;<br \/>\nend if ;<\/p>\n<p>return l_return_val;<\/p>\n<p>exception<\/p>\n<p>when others then<br \/>\nl_return_val := p_in ;<\/p>\n<p>return l_return_val;<br \/>\nend;<br \/>\n\/<\/p>\n<p>&nbsp;<\/p>\n<p>3. \ubcf5\ud638\ud654 \uc554\ud638 \ud568\uc218<\/p>\n<p>CREATE OR REPLACE function decodeParam<br \/>\n(<br \/>\np_in\u00a0\u00a0\u00a0 in varchar2<br \/>\n)<br \/>\nreturn varchar2 is<br \/>\nl_return_val varchar2(2048) ;<br \/>\nl_dec_val raw (2048);<br \/>\nl_mod\u00a0\u00a0\u00a0\u00a0 number := DBMS_CRYPTO.ENCRYPT_AES256<br \/>\n+ DBMS_CRYPTO.CHAIN_ECB<br \/>\n+ DBMS_CRYPTO.PAD_PKCS5;<br \/>\np_key raw (65) ;<br \/>\nbegin<\/p>\n<p>if p_in is not null and (isEncoded(p_in)&gt;0) then<\/p>\n<p>select key into p_key from sy_secure_key ;<\/p>\n<p>l_dec_val := utl_encode.base64_decode(utl_raw.cast_to_raw(p_in)) ;<br \/>\nl_dec_val := DBMS_CRYPTO.decrypt( l_dec_val, l_mod, p_key );<br \/>\nl_return_val := UTL_RAW.cast_to_varchar2( l_dec_val) ;<\/p>\n<p>else<br \/>\nl_return_val := p_in ;<br \/>\nend if ;<\/p>\n<p>return l_return_val;<\/p>\n<p>exception<\/p>\n<p>when others then<br \/>\nl_return_val := p_in ;<\/p>\n<p>return l_return_val;<br \/>\nend;<br \/>\n\/<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>4. \uc554\ud638\ud654 \ud14c\uc774\ube14 \ub370\uc774\ud130 \uc870\ud68c \uc2dc ( \ubcf5\ud638\ud654 \uacfc\uc815 )<\/p>\n<p>select\u00a0 decodeParam(COL1), decodeParam(COL2)<br \/>\nfrom \uac1c\uc778\uc815\ubcf4\ud14c\uc774\ube14<br \/>\nwhere ID=&#8217;haisins&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>5. \uc554\ud638\ud654 \ud14c\uc774\ube14 \ub370\uc774\ud130 \ucd94\uac00 \uc2dc ( \uc554\ud638\ud654 \uacfc\uc815 )<\/p>\n<p>Insert into \uac1c\uc778\uc815\ubcf4\ud14c\uc774\ube14\u00a0 values (encodeParam(\u2018\uc8fc\ubbfc\ubc88\ud638\u2019) ;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>*.\ucc38\uace0<\/p>\n<p class=\"titleintable\" style=\"text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; margin-top: 16px; margin-bottom: 16px; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; background-color: #ffffff; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;\"><span style=\"font-size: 10pt;\">DBMS_CRYPTO Encryption Algorithms<\/span><\/p>\n<table class=\"Formal\" dir=\"ltr\" style=\"text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; border-collapse: separate; orphans: 2; widows: 2; background-color: #ffffff; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;\" title=\"DBMS_CRYPTO Encryption Algorithms\" border=\"1\" summary=\"This table describes DBMS_CRYPTO Encryption algorithms.\" width=\"100%\" frame=\"hsides\" rules=\"groups\" cellspacing=\"0\" cellpadding=\"3\">\n<colgroup>\n<col width=\"31%\" \/>\n<col width=\"*\" \/><\/colgroup>\n<thead style=\"vertical-align: middle;\">\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<th id=\"r1c1-t7\" style=\"padding: 1px; vertical-align: bottom;\" align=\"left\" valign=\"bottom\"><span style=\"font-size: 10pt;\">Name<\/span><\/th>\n<th id=\"r1c2-t7\" style=\"padding: 1px; vertical-align: bottom;\" align=\"left\" valign=\"bottom\"><span style=\"font-size: 10pt;\">Description<\/span><\/th>\n<\/tr>\n<\/thead>\n<tbody style=\"vertical-align: middle;\">\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r2c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\">\n<pre class=\"inline:true style:line-height: normal; white-space: normal; decode:1 \">&lt;span style=&quot;font-size: 8.7pt;&quot;&gt;ENCRYPT_DES&lt;\/span&gt;<\/pre>\n<\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r2c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Data Encryption Standard. Block cipher. Uses key length of 56 bits.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r3c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\">\n<pre class=\"inline:true style:line-height: normal; white-space: normal; decode:1 \">&lt;span style=&quot;font-size: 8.7pt;&quot;&gt;ENCRYPT_3DES_2KEY&lt;\/span&gt;<\/pre>\n<\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r3c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Data Encryption Standard. Block cipher. Operates on a block 3 times with 2 keys. Effective key length of 112 bits.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r4c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\">\n<pre class=\"inline:true style:line-height: normal; white-space: normal; decode:1 \">&lt;span style=&quot;font-size: 8.7pt;&quot;&gt;ENCRYPT_3DES&lt;\/span&gt;<\/pre>\n<\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r4c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Data Encryption Standard. Block cipher. Operates on a block 3 times.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r5c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">ENCRYPT_AES128<\/span><\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r5c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Advanced Encryption Standard. Block cipher. Uses 128-bit key size.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r6c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">ENCRYPT_AES192<\/span><\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r6c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Advanced Encryption Standard. Block cipher. Uses 192-bit key size.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r7c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">ENCRYPT_AES256<\/span><\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r7c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Advanced Encryption Standard. Block cipher. Uses 256-bit key size.<\/span><\/p>\n<\/td>\n<\/tr>\n<tr style=\"vertical-align: middle;\" align=\"left\" valign=\"top\">\n<td id=\"r8c1-t7\" style=\"padding: 1px; vertical-align: top;\" headers=\"r1c1-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\">\n<pre class=\"inline:true style:line-height: normal; white-space: normal; decode:1 \">&lt;span style=&quot;font-size: 8.7pt;&quot;&gt;ENCRYPT_RC4&lt;\/span&gt;<\/pre>\n<\/p>\n<\/td>\n<td style=\"padding: 1px; vertical-align: top;\" headers=\"r8c1-t7 r1c2-t7\" align=\"left\">\n<p style=\"line-height: normal; margin-top: 0px; margin-bottom: 0px;\"><span style=\"font-size: 10pt;\">Stream cipher. Uses a secret, randomly generated key unique to each session.<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a title=\"https:\/\/docs.oracle.com\/cd\/E18283_01\/appdev.112\/e16760\/d_crypto.htm\" href=\"https:\/\/docs.oracle.com\/cd\/E18283_01\/appdev.112\/e16760\/d_crypto.htm\">https:\/\/docs.oracle.com\/cd\/E18283_01\/appdev.112\/e16760\/d_crypto.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud0c0 \uc0ac\uc774\ud2b8\uc5d0\uc11c \uc0ac\uc6a9 \ud588\ub358 \uc624\ub77c\ud074 DB\uc758 \uae30\ubcf8 \uc81c\uacf5 \uc554\ud638\ud654 \ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c \ucd94\uac00 \uc554\ud638\ud654 \uc194\ub8e8\uc158 \uad6c\ub9e4 \uc5c6\uc774 \uac1c\uc778\uc815\ubcf4 \ub370\uc774\ud130 \ub97c\u00a0 \uceec\ub7fc \ub2e8\uc704 \uc554\ud638\ud654 \ud558\ub294\u00a0 \ubc29\ubc95 \uc785\ub2c8\ub2e4. \uc591\ubc29\ud5a5 \uc554\ud638\ud654 &lt; \uc694\uc57d &gt; \uc544\ub798 \ubc29\uc2dd\uc73c\ub85c \ud0a4 \ud14c\uc774\ube14\uacfc \uc554\ud638\ud654 \/ \ubcf5\ud638\ud654 \ud568\uc218\ub97c \ub9cc\ub4e0 \ub2e4\uc74c \uac1c\uc778\uc815\ubcf4 \ub370\uc774\ud130\ub97c \uc785\ub825 , \uc218\uc815 , \uc870\ud68c \ud558\ub294 \ubd80\ubd84\uc744 \ubaa8\ub450 \ubcc0\uacbd ( SQL , SP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2428,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"spay_email":""},"categories":[336],"tags":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/haisins.synology.me\/wordpress\/wp-content\/uploads\/2018\/01\/Bull-cyber-Data-encryption-1.jpg?fit=538%2C303","amp_enabled":true,"_links":{"self":[{"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2423"}],"collection":[{"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2423"}],"version-history":[{"count":3,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2423\/revisions"}],"predecessor-version":[{"id":4510,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2423\/revisions\/4510"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/2428"}],"wp:attachment":[{"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2423"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/haisins.synology.me\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}