Skip to content

Commit

Permalink
KG이니시스 통합인증 암호화적용 여부 선택옵션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
thisgun committed Apr 11, 2024
1 parent 2aff3cd commit 470d65d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
15 changes: 15 additions & 0 deletions adm/config_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@
ADD COLUMN `cf_cert_kg_mid` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cf_cert_kg_cd`; ";
sql_query($sql, false);
}
if (!isset($config['cf_cert_use_seed'])) {
$sql = "ALTER TABLE `{$g5['config_table']}`
ADD COLUMN `cf_cert_use_seed` TINYINT(4) NOT NULL DEFAULT '0' AFTER `cf_cert_kg_mid`; ";
sql_query($sql, false);
}
if (!$config['cf_faq_skin']) {
$config['cf_faq_skin'] = "basic";
}
Expand Down Expand Up @@ -1003,6 +1008,16 @@
</select>
</td>
</tr>
<tr>
<th scope="row" class="cf_cert_service"><label for="cf_cert_use_seed">통합인증 암호화 적용</label></th>
<td class="cf_cert_service">
<?php echo help('KG이니시스 통합인증서비스에 암호화를 적용합니다. 만일 글자가 깨지는 문제가 발생하면 사용안함으로 적용해 주세요.') ?>
<select name="cf_cert_use_seed" id="cf_cert_use_seed">
<?php echo option_selected("0", $config['cf_cert_use_seed'], "사용안함"); ?>
<?php echo option_selected("1", $config['cf_cert_use_seed'], "사용함"); ?>
</select>
</td>
</tr>
<tr>
<th scope="row" class="cf_cert_service"><label for="cf_cert_hp">휴대폰 본인확인</label></th>
<td class="cf_cert_service">
Expand Down
2 changes: 2 additions & 0 deletions adm/config_form_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
'cf_cert_ipin' => 'char',
'cf_cert_hp' => 'char',
'cf_cert_simple' => 'char',
'cf_cert_use_seed' => 'int',
'cf_admin_email' => 'char',
'cf_admin_email_name' => 'char',
'cf_add_script' => 'text',
Expand Down Expand Up @@ -284,6 +285,7 @@
cf_cert_ipin = '{$_POST['cf_cert_ipin']}',
cf_cert_hp = '{$_POST['cf_cert_hp']}',
cf_cert_simple = '{$_POST['cf_cert_simple']}',
cf_cert_use_seed = '".(int)$_POST['cf_cert_use_seed']."',
cf_cert_kg_cd = '{$_POST['cf_cert_kg_cd']}',
cf_cert_kg_mid = '" . trim($_POST['cf_cert_kg_mid']) . "',
cf_cert_kcb_cd = '{$_POST['cf_cert_kcb_cd']}',
Expand Down
2 changes: 2 additions & 0 deletions extend/default.config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

define('KGINICIS_USE_CERT_SEED', isset($config['cf_cert_use_seed']) ? (int) $config['cf_cert_use_seed'] : 0);

// 유저 사이드뷰에서 아이콘 지정 안했을시 기본 no 프로필 이미지
define('G5_NO_PROFILE_IMG', '<span class="profile_img"><img src="'.G5_IMG_URL.'/no_profile.gif" alt="no_profile" width="'.$config['cf_member_icon_width'].'" height="'.$config['cf_member_icon_height'].'"></span>');

Expand Down
1 change: 1 addition & 0 deletions install/gnuboard5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ CREATE TABLE IF NOT EXISTS `g5_config` (
`cf_cert_simple` varchar(255) NOT NULL DEFAULT '',
`cf_cert_kg_cd` varchar(255) NOT NULL DEFAULT '',
`cf_cert_kg_mid` varchar(255) NOT NULL DEFAULT '',
`cf_cert_use_seed` tinyint(4) NOT NULL DEFAULT '0',
`cf_cert_kcb_cd` varchar(255) NOT NULL DEFAULT '',
`cf_cert_kcp_cd` varchar(255) NOT NULL DEFAULT '',
`cf_lg_mid` varchar(100) NOT NULL DEFAULT '',
Expand Down
2 changes: 1 addition & 1 deletion plugin/inicert/ini_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$mTxId ='SIR_'.$max_cr_id;
}
$reqSvcCd ='01'; // 요청구분코드 ["01":간편인증, "02":전자서명]
$reservedMsg ='isUseToken=Y'; // 결과조회 응답시 개인정보SEED 암호화 처리 요청
$reservedMsg = (defined('KGINICIS_USE_CERT_SEED') && KGINICIS_USE_CERT_SEED) ? 'isUseToken=Y' : ''; // 결과조회 응답시 개인정보SEED 암호화 처리 요청

// 등록가맹점 확인
$plainText1 = hash("sha256",(string)$mid.(string)$mTxId.(string)$apiKey);
Expand Down
12 changes: 7 additions & 5 deletions plugin/inicert/ini_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
$birth_day = $res_data['userBirthday']; // 생년월일
$ci = $res_data['userCi']; // CI

// 개인정보SEED 암호화 된것을 복호화 합니다.
$user_name = decrypt_SEED($user_name, $SEEDKEY, $SEEDIV);
$phone_no = decrypt_SEED($phone_no, $SEEDKEY, $SEEDIV);
$birth_day = decrypt_SEED($birth_day, $SEEDKEY, $SEEDIV);
$ci = decrypt_SEED($ci, $SEEDKEY, $SEEDIV);
if (defined('KGINICIS_USE_CERT_SEED') && KGINICIS_USE_CERT_SEED) {
// 개인정보SEED 암호화 된것을 복호화 합니다.
$user_name = decrypt_SEED($user_name, $SEEDKEY, $SEEDIV);
$phone_no = decrypt_SEED($phone_no, $SEEDKEY, $SEEDIV);
$birth_day = decrypt_SEED($birth_day, $SEEDKEY, $SEEDIV);
$ci = decrypt_SEED($ci, $SEEDKEY, $SEEDIV);
}

@insert_cert_history($member['mb_id'], 'inicis', $cert_type); // 인증성공 시 내역 기록

Expand Down
3 changes: 2 additions & 1 deletion plugin/inicert/libs/INILib.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ function decrypt_SEED($str, $bszUser_key, $bszIV) {
$pdwRoundKey = array_pad(array(), 32, 0);

$bszPlainText = null;
$planBytresMessage = array();

// 방법 1
$bszPlainText = KISA_SEED_CBC::SEED_CBC_Decrypt($keyBytes, $IVBytes, $planBytes, 0, count($planBytes));
for ($i = 0; $i < sizeof($bszPlainText); $i++) {
for ($i = 0; $i < sizeof((array) $bszPlainText); $i++) {
$planBytresMessage[] = sprintf("%02X", $bszPlainText[$i]);
}
return Hex2String($planBytresMessage);
Expand Down
4 changes: 2 additions & 2 deletions plugin/inicert/libs/KISA_SEED_CBC.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class KISA_SEED_KEY {

var $key_data = null;

function KISA_SEED_KEY() {
function __construct() {
$this->key_data = array_pad(array(), 32, 0);
}

Expand All @@ -192,7 +192,7 @@ class KISA_SEED_INFO {
var $cbc_last_block = null;
var $last_block_flag = 0;

function KISA_SEED_INFO() {
function __construct() {
$this->ivec = array_pad(array(), 4, 0);
$this->seed_key = new KISA_SEED_KEY();
$this->cbc_buffer = array_pad(array(), 4, 0);
Expand Down

0 comments on commit 470d65d

Please sign in to comment.