@@ -92,17 +92,6 @@ local function init_iv_tbl(ivs)
9292end
9393
9494
95- local _aes_128_cbc_with_iv_tbl_ssl
96- local function get_aes_128_cbc_with_iv_ssl (local_conf )
97- if _aes_128_cbc_with_iv_tbl_ssl == nil then
98- local ivs = core .table .try_read_attr (local_conf , " apisix" , " ssl" , " key_encrypt_salt" )
99- _aes_128_cbc_with_iv_tbl_ssl = init_iv_tbl (ivs )
100- end
101-
102- return _aes_128_cbc_with_iv_tbl_ssl
103- end
104-
105-
10695local _aes_128_cbc_with_iv_tbl_gde
10796local function get_aes_128_cbc_with_iv_gde (local_conf )
10897 if _aes_128_cbc_with_iv_tbl_gde == nil then
@@ -127,43 +116,31 @@ end
127116
128117function _M .aes_encrypt_pkey (origin , field )
129118 local local_conf = core .config .local_conf ()
119+ local aes_128_cbc_with_iv_tbl_gde = get_aes_128_cbc_with_iv_gde (local_conf )
120+ local aes_128_cbc_with_iv_gde = aes_128_cbc_with_iv_tbl_gde [1 ]
130121
131122 if not field then
132- -- default used by ssl
133- local aes_128_cbc_with_iv_tbl_ssl = get_aes_128_cbc_with_iv_ssl (local_conf )
134- local aes_128_cbc_with_iv_ssl = aes_128_cbc_with_iv_tbl_ssl [1 ]
135- if aes_128_cbc_with_iv_ssl ~= nil and core .string .has_prefix (origin , " ---" ) then
136- return encrypt (aes_128_cbc_with_iv_ssl , origin )
123+ if aes_128_cbc_with_iv_gde ~= nil and core .string .has_prefix (origin , " ---" ) then
124+ return encrypt (aes_128_cbc_with_iv_gde , origin )
137125 end
138126 else
139127 if field == " data_encrypt" then
140- local aes_128_cbc_with_iv_tbl_gde = get_aes_128_cbc_with_iv_gde (local_conf )
141- local aes_128_cbc_with_iv_gde = aes_128_cbc_with_iv_tbl_gde [1 ]
142128 if aes_128_cbc_with_iv_gde ~= nil then
143129 return encrypt (aes_128_cbc_with_iv_gde , origin )
144130 end
145131 end
146132 end
147-
148133 return origin
149134end
150135
151136
152137local function aes_decrypt_pkey (origin , field )
153- local local_conf = core .config .local_conf ()
154- local aes_128_cbc_with_iv_tbl
155-
156- if not field then
157- if core .string .has_prefix (origin , " ---" ) then
158- return origin
159- end
160- aes_128_cbc_with_iv_tbl = get_aes_128_cbc_with_iv_ssl (local_conf )
161- else
162- if field == " data_encrypt" then
163- aes_128_cbc_with_iv_tbl = get_aes_128_cbc_with_iv_gde (local_conf )
164- end
138+ if not field and core .string .has_prefix (origin , " ---" ) then
139+ return origin
165140 end
166141
142+ local local_conf = core .config .local_conf ()
143+ local aes_128_cbc_with_iv_tbl = get_aes_128_cbc_with_iv_gde (local_conf )
167144 if # aes_128_cbc_with_iv_tbl == 0 then
168145 return origin
169146 end
0 commit comments