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
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
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/app_info/helper/signatures.rb', line 186 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
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/app_info/helper/signatures.rb', line 217 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
204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/app_info/helper/signatures.rb', line 204 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
170 171 172 173 174 175 |
# File 'lib/app_info/helper/signatures.rb', line 170 def best_algorithem(algorithems) methods = algorithems.map { |algorithem| algorithem[:method] } best_method = methods.max { |a, b| algorithem_priority(a) <=> algorithem_priority(b) } best_method_index = methods.index(best_method) algorithems[best_method_index] end |
#compare_algorithem(source, target) ⇒ Object
177 178 179 180 181 182 183 184 |
# File 'lib/app_info/helper/signatures.rb', line 177 def compare_algorithem(source, target) case algorithem_priority(source) <=> algorithem_priority(target) when -1 target else source end end |