*&---------------------------------------------------------------------*
* & Report z_xl_slmk
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
Report
Z_xl_slmk.
.
Parameters
: P_sid (3
) Type
C
,
P_sysno (2
),
P_server (10
),
P_instno (10
).
Data
:
P_pf_sid (3
), "Sid of SAP system
P_pf_sysno (2
), "Central instance number
P_pf_server (10
), "Message Server Host Name, less than 10 chars
P_pf_instno (10
), "Installation Number
P_pf_value (20
). "Solman key for installation and upgrade
Start-
-Selection.
P_pf_sid = p_sid.
P_pf_sysno = p_sysno.
P_pf_server = p_server.
P_pf_instno = p_instno.
Perform
Get_sp_value using
P_pf_sid
P_pf_sysno
P_pf_server
P_pf_instno
Changing
P_pf_value.
Write
:/'Key :'
, P_pf_value.
Form
Get_sp_value using
P_pf_sid
P_pf_sysno
P_pf_server
P_pf_instno
Changing
P_pf_value.
Constants
: Lc_part_len type
I
Value
5
,
Lc_pw_len type
I
Value
10
,
Lc_allowed_chars (38
) Type
C
Value
'-0123456789abcdefghijklmnopqrstuvwxyz _'
.
Data
: Lf_string (20
) Type
C
,
Lf_key type
I
,
* Ls_key type dswpclientkey,
Lf_part (lc_part_len) Type
C
,
Lf_finalf (lc_pw_len) Type
C
,
Lf_finalx type
Xstring,
Lf_xbuffer type
Xstring,
Lf_opf (10
) Type
C
,
Lf_langu like
Sy-Langu,
Lf_subrc like
Sy-subrc,
Lf_len type
I
,
Lo_conv_to_x type
Ref
To
Cl_abap_conv_out_ce.
Clear
: Lf_string, lf_finalx, lf_opf.
Concatenate
P_pf_sid p_pf_sysno p_pf_server
Lf_string.
* Large letters only
Translate
Lf_string
Upper
Case
.
Lf_langu = sy-Langu.
Set
Locale
Language
'E'
.
Lo_conv_to_x = cl_abap_conv_out_ce => Create (Encoding
= '000000'
).
Lf_len = strlen
(Lf_string ).
If
Lf_string (lf_len) Cn
Lc_allowed_chars.
Else
.
* Fold the input string to a lc_part_len long string
While
Lf_len> 0
.
Lf_part = lf_string (lc_part_len ).
Shift
Lf_string
Lc_part_len places
.
Lf_len = strlen
(Lf_string ).
Call
Method
Lo_conv_to_x-> Reset.
Call
Method
Lo_conv_to_x-> write (Data
= Lf_part n =-1
).
Lf_xbuffer = lo_conv_to_x-> get_buffer ().
Lf_finalx = lf_finalx bit
-XOR
Lf_xbuffer.
Endwhile
.
Lf_key = 12
.
Perform
Scramble using
Lf_finalx
Lf_key
Lc_part_len
Changing
Lf_finalf
Lf_subrc.
If
Lf_subrc EQ
0
.
P_pf_value = lf_finalf.
Endif
.
* If not lf_finalf is initial.
* P_pf_value = lf_finalf.
* Ls_key-dbid = p_pf_sid.
* Ls_key-instno = p_pf_instno.
* Ls_key-bundle_id = 'sm _ key '.
* Ls_key-service_key = lf_finalf.
* If not p_pf_instno is initial.
* Insert dswpclientkey from ls_key.
* If sy-subrc <> 0.
* Update dswpclientkey from ls_key.
* Endif.
* Endif.
* Else.
* Clear p_pf_value.
* Endif.
Endif
.
Endform
. "Get_sp_value
Form
Scramble using
Iv_xstring type
Xstring
Iv_key type
I
Iv_src_len type
I
Changing
Lf_finalf
Lf_subrc like
Sy-subrc.
Constants
: Lc_max_len type
I
Value
20
,
Lc_mask (4
) Type
X
Value
'0000003f'
,
Lc_random (64
) Type
X
Value
'F0ed53b83244f1f876c67959fd4f13a2'
&
'C15195ec5483c234774943a27de26596'
&
'5e5398789a17a33cd383a8b829fbdca5'
&
'55d702778413acddf9b83116610e6dfa'
.
Data
: Lv_key_index (4
) Type
X
,
Lv_rand_index (4
) Type
X
,
Lv_xkey (4
) Type
X
,
Lv_xkey_shl_1 (4
) Type
X
,
Lv_xkey_shr_5 (4
) Type
X
,
Lv_scramble_byte type
X
,
Lv_dest (lc_max_len) Type
X
,
Lv_index type
I
,
Lv_len type
I
.
If
Iv_src_len EQ
0
. Exit
. Endif
.
Lv_len = xstrlen
(Iv_xstring ).
If
Iv_src_len GT
Lc_max_len or
Iv_src_len GT
Lv_len.
Lf_subrc = 2
.
Exit
.
Endif
.
Lv_xkey = iv_key.
Lv_xkey_shl_1 = iv_key * 2
.
Lv_xkey_shr_5 = iv_key Div
32
.
Lv_rand_index = lv_xkey bit
-XOR
Lv_xkey_shr_5 bit
-XOR
Lv_xkey_shl_1.
Lv_rand_index = lv_rand_index bit
-And
Lc_mask.
Lv_index = 0
.
Do
Iv_src_len times
.
Catch
System-Exceptions
Compute_int_times_overflow = 1
.
Lv_key_index = (iv_key * lv_index)-lv_index.
Endcatch.
If
Sy-subrc <> 0
.
Lf_subrc = 1
.
Exit
.
Endif
.
Lv_scramble_byte = lc_random + lv_rand_index (1
) Bit
-XOR
Lv_key_index + 3
(1
).
Lv_dest + lv_index (1
) = Iv_xstring + lv_index (1
) Bit
-XOR
Lv_scramble_byte.
Lv_index = lv_index + 1
.
Lv_rand_index = lv_rand_index + 1
.
Lv_rand_index = lv_rand_index bit
-And
Lc_mask.
Enddo
.
If
Lf_subrc <> 0
.
Exit
.
Endif
.
Write
Lv_dest (iv_src_len)
Lf_finalf.
Endform
.