[General Questions and Answers] lihkin12:
Android's /data/system/packages.xml contains a cert node that has a "key" attribute. How is that key attribute datastring generated? For example:

<package name="packageName" codePath="/data/app/packageName-4r-3P8gvwV53t8CAY1HaqQ==" nativeLibraryPath="/data/app/ packageName -4r-3P8gvwV53t8CAY1HaqQ==/lib" primaryCpuAbi="arm64-v8a" publicFlags="944275012" privateFlags="0" ft="1794526df30" it="179452759d5" ut="179452759d5" version="60" userId="10346">

<sigs count="1">

<cert index="17" key = "3082056f30820357a00302010202020357300d06092a864886f70d01010b0500306d310b3009060355040613025553311d301b060355040a131453796d616e74656320436f72706f726174696f6e311d301b060355040b1314416e64726f6964204170706c69636174696f6e733120301e0603550403131753796d616e74656320434120666f7220416e64726f6964301e170d3136313131353132343332345a170d3431313131303135353832315a3075310b300906035504061302494e311430120603550408130b4d61686172617368747261311430120603550407130b4e617669204d756d626169311c301a060355040a131353544154452042414e4b204f4620494e444941311c301a0603550403131353544154452042414e4b204f4620494e44494130820122300d06092a864886f70d01010105000382010f003082010a0282010100b40850398200afe7647c734cb4a04f2b67eee915301f6c5e8d5b7fbae3defa4b7c27894d35cceef222009333843b5e49c9382e64822d00fd0a8667f470f5fbeed677b768cbe4f39f9b71f10d6db2070d63220108a4e183e937fbf00ac3e69bf726890b9242c70262fbdd564ddbc4e63701d912df1f37e9b7dcb28b7b13b9fdd33a9f3bbba0fefbbbdcff30c3c605db8b6d61675b86f486d185cfdfe7c1ad73a4618a1b0f383d3d9b5c26ed6007cf89601453617fb07ef40daa4a307044e0eb8a6ce5cc7422fea1b2d244c6fb39a830368ac7b2855ee580c13e11b25bb8d0ae426c262303e7dd1b3bc84ada65f2cd758efce96700c91a5827331a7fc40f9a72870203010001a382010f3082010b301f0603551d230418301680148e55d1a566d0a824974eec77d0dcbea0936884dd303c06082b060105050701010430302e302c06082b060105050730018620687474703a2f2f616e64726f69642d6f6373702e67656f74727573742e636f6d300e0603551d0f0101ff0404030205e0302a0603551d250423302106082b0601050507030206082b06010505070303060b6086480186f8450108350130410603551d1f043a30383036a034a0328630687474703a2f2f616e64726f69642d63726c2e67656f74727573742e636f6d2f63726c732f616e64726f69642e63726c301d0603551d0e04160414c42e45c7eb54079d944c0a915e3c390544a20194300c0603551d130101ff04023000300d06092a864886f70d01010b0500038202010063e29f0f7c49b6f1724bd34376cda80acf1f2bb0fb5d5a50d84caa3862458b5dd8e5ac184c98bc424dd667e326938b003b7bdc05f9bfb449fa19fe52d7389d929b0979064cd6b1cd48e9c49b41a0a24ddd9968f3a98631a99f40213bc181f61f32b327016fcaff475cea7f8242fe0a571cf5d89fb26be0a0049050d57b5fdb9e8e75a439a6e6d42c324163ab39b2482aba1274dba663d94bbdc0bca47ad7d4d5fbe1cb41f8c2ea9d9be6c4de553aeaf9e82d8318034f37dadd5579edb1d43dd2ced3988353fe7c3a12e350dc188aa5019c96d3384fa2b6201335644d6650263fa92118ac18c1a571150fa9a16c2ca68dde38982cb9dd02fa8aac9c6dcfa40fcf95b858540434fa38c6e22cf65649c3844932a9fe77c4fabdf649787ba63978f19e1c4a696e678347a21b65908e67a543d1650544d5107499770b1ed82c1276edcaeb57cc8489bfab7e976621d6c8458c7ef4a4e5938afe6315fadfd11b818587f04ee23462bbef13a2825b6334a0154fd69de8b23be81129f5f328782f0222717481d155a478d02af378ab7d01427bbfdf33934bc113d8a8d34676487316c5d7c5861689ea8bd5ffb89e079295ac583bdf309deda1f9b40506dd204291fe5c062c88963600bbc573fabed63022b40cecb9b1858603b6a7532952c3742c7259e7185e5e2b3da5673a9a25b28327c71657770e30f4436d062444b15d82c553968d" />

</sigs>

I want to generate the same key value from the *.RSA file present inside the apk. I tried the following things but it did not work out:

Executed the command unzip -p path_to_appName.apk META-INF/CERT.RSA | xxd -p | tr -d '\n' (but it gave incorrect result)

openssl pkcs7 -inform DER -in filename.RSA -noout -print_certs -text

Tried to fetch the certificate details of the app using the above command and tried analysing the public key of the app but could not find any pattern

Does anyone know how to generate the key value from the signature file (*.RSA) file present inside the apk?

Thanks a lot for the help