Module: AppInfo::Helper::Algorithm
- Included in:
- Android::Signature::V2, Android::Signature::V3
- Defined in:
- lib/app_info/helper/signatures.rb
Overview
Signature Algorithm helper
Constant Summary collapse
- SIG_RSA_PSS_WITH_SHA256 =
Signature certificate identifiers
[0x01, 0x01, 0x00, 0x00].freeze
- SIG_RSA_PSS_WITH_SHA512 =
0x0102
[0x02, 0x01, 0x00, 0x00].freeze
- SIG_RSA_PKCS1_V1_5_WITH_SHA256 =
0x0103
[0x03, 0x01, 0x00, 0x00].freeze
- SIG_RSA_PKCS1_V1_5_WITH_SHA512 =
0x0104
[0x04, 0x01, 0x00, 0x00].freeze
- SIG_ECDSA_WITH_SHA256 =
0x0201
[0x01, 0x02, 0x00, 0x00].freeze
- SIG_ECDSA_WITH_SHA512 =
0x0202
[0x02, 0x02, 0x00, 0x00].freeze
- SIG_DSA_WITH_SHA256 =
0x0301
[0x01, 0x03, 0x00, 0x00].freeze
- SIG_VERITY_RSA_PKCS1_V1_5_WITH_SHA256 =
0x0421
[0x21, 0x04, 0x00, 0x00].freeze
- SIG_VERITY_ECDSA_WITH_SHA256 =
0x0423
[0x23, 0x04, 0x00, 0x00].freeze
- SIG_VERITY_DSA_WITH_SHA256 =
0x0425
[0x25, 0x04, 0x00, 0x00].freeze
- SIG_STRIPPING_PROTECTION_ATTR_ID =
0xbeeff00d
[0x0d, 0xf0, 0xef, 0xbe].freeze
- SIG_PROOF_OF_ROTATION_ATTR_ID =
0x3ba06f8c
[0x8c, 0x6f, 0xa0, 0x3b].freeze
Instance Method Summary collapse
- #algorithem_priority(algorithm) ⇒ Object
- #algorithm_match(algorithm) ⇒ Object
- #algorithm_method(algorithm) ⇒ Object
- #best_algorithem(algorithems) ⇒ Object
- #compare_algorithem(source, target) ⇒ Object
Instance Method Details
#algorithem_priority(algorithm) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/app_info/helper/signatures.rb', line 198 def algorithem_priority(algorithm) case algorithm when SIG_RSA_PSS_WITH_SHA256, SIG_RSA_PKCS1_V1_5_WITH_SHA256, SIG_ECDSA_WITH_SHA256, SIG_DSA_WITH_SHA256 1 when SIG_RSA_PSS_WITH_SHA512, SIG_RSA_PKCS1_V1_5_WITH_SHA512, SIG_ECDSA_WITH_SHA512 2 when SIG_VERITY_RSA_PKCS1_V1_5_WITH_SHA256, SIG_VERITY_ECDSA_WITH_SHA256, SIG_VERITY_DSA_WITH_SHA256 3 end end |
#algorithm_match(algorithm) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/app_info/helper/signatures.rb', line 229 def algorithm_match(algorithm) case algorithm when SIG_RSA_PSS_WITH_SHA256, SIG_RSA_PKCS1_V1_5_WITH_SHA256, SIG_ECDSA_WITH_SHA256, SIG_DSA_WITH_SHA256, SIG_VERITY_RSA_PKCS1_V1_5_WITH_SHA256, SIG_VERITY_ECDSA_WITH_SHA256, SIG_VERITY_DSA_WITH_SHA256 'SHA256' when SIG_RSA_PSS_WITH_SHA512, SIG_RSA_PKCS1_V1_5_WITH_SHA512, SIG_ECDSA_WITH_SHA512 'SHA512' end end |
#algorithm_method(algorithm) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/app_info/helper/signatures.rb', line 216 def algorithm_method(algorithm) case algorithm when SIG_RSA_PSS_WITH_SHA256, SIG_RSA_PSS_WITH_SHA512, SIG_RSA_PKCS1_V1_5_WITH_SHA256, SIG_RSA_PKCS1_V1_5_WITH_SHA512, SIG_VERITY_RSA_PKCS1_V1_5_WITH_SHA256 :rsa when SIG_ECDSA_WITH_SHA256, SIG_ECDSA_WITH_SHA512, SIG_VERITY_ECDSA_WITH_SHA256 :ec when SIG_DSA_WITH_SHA256, SIG_VERITY_DSA_WITH_SHA256 :dsa end end |
#best_algorithem(algorithems) ⇒ Object
185 186 187 |
# File 'lib/app_info/helper/signatures.rb', line 185 def best_algorithem(algorithems) algorithems.max_by { |algorithem| algorithem_priority(algorithem[:id]) || -1 } end |
#compare_algorithem(source, target) ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/app_info/helper/signatures.rb', line 189 def compare_algorithem(source, target) case algorithem_priority(source) <=> algorithem_priority(target) when -1 target else source end end |