Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //! Utilities for Signature Verification |
| 18 | |
Alice Wang | 5d0f89a | 2022-09-15 15:06:10 +0000 | [diff] [blame] | 19 | use anyhow::{anyhow, ensure, Error, Result}; |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 20 | use byteorder::{LittleEndian, ReadBytesExt}; |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 21 | use bytes::{Buf, BufMut, Bytes, BytesMut}; |
Andrew Scull | c208eb4 | 2022-05-22 16:17:52 +0000 | [diff] [blame] | 22 | use openssl::hash::{DigestBytes, Hasher, MessageDigest}; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 23 | use std::cmp::min; |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 24 | use std::io::{self, Cursor, ErrorKind, Read, Seek, SeekFrom, Take}; |
Jooyung Han | 5d94bfc | 2021-08-06 14:07:49 +0900 | [diff] [blame] | 25 | |
Alice Wang | 5d0f89a | 2022-09-15 15:06:10 +0000 | [diff] [blame] | 26 | use crate::algorithms::SignatureAlgorithmID; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 27 | use crate::ziputil::{set_central_directory_offset, zip_sections}; |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 28 | |
| 29 | const APK_SIG_BLOCK_MIN_SIZE: u32 = 32; |
| 30 | const APK_SIG_BLOCK_MAGIC: u128 = 0x3234206b636f6c4220676953204b5041; |
| 31 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 32 | const CHUNK_SIZE_BYTES: u64 = 1024 * 1024; |
Alice Wang | 2ef3074 | 2022-09-19 11:59:17 +0000 | [diff] [blame] | 33 | const CHUNK_HEADER_TOP: &[u8] = &[0x5a]; |
| 34 | const CHUNK_HEADER_MID: &[u8] = &[0xa5]; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 35 | |
Alice Wang | ed79eab | 2022-09-08 11:16:31 +0000 | [diff] [blame] | 36 | /// The [APK structure] has four major sections: |
| 37 | /// |
| 38 | /// | Zip contents | APK Signing Block | Central directory | EOCD(End of Central Directory) | |
| 39 | /// |
| 40 | /// This structure contains the offset/size information of all the sections except the Zip contents. |
| 41 | /// |
| 42 | /// [APK structure]: https://source.android.com/docs/security/apksigning/v2#apk-signing-block |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 43 | pub struct ApkSections<R> { |
| 44 | inner: R, |
| 45 | signing_block_offset: u32, |
| 46 | signing_block_size: u32, |
| 47 | central_directory_offset: u32, |
| 48 | central_directory_size: u32, |
| 49 | eocd_offset: u32, |
| 50 | eocd_size: u32, |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 51 | } |
| 52 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 53 | impl<R: Read + Seek> ApkSections<R> { |
| 54 | pub fn new(reader: R) -> Result<ApkSections<R>> { |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 55 | let (mut reader, zip_sections) = zip_sections(reader)?; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 56 | let (signing_block_offset, signing_block_size) = |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 57 | find_signing_block(&mut reader, zip_sections.central_directory_offset)?; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 58 | Ok(ApkSections { |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 59 | inner: reader, |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 60 | signing_block_offset, |
| 61 | signing_block_size, |
| 62 | central_directory_offset: zip_sections.central_directory_offset, |
| 63 | central_directory_size: zip_sections.central_directory_size, |
| 64 | eocd_offset: zip_sections.eocd_offset, |
| 65 | eocd_size: zip_sections.eocd_size, |
| 66 | }) |
| 67 | } |
Jooyung Han | 5d94bfc | 2021-08-06 14:07:49 +0900 | [diff] [blame] | 68 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 69 | /// Returns the APK Signature Scheme block contained in the provided file for the given ID |
| 70 | /// and the additional information relevant for verifying the block against the file. |
| 71 | pub fn find_signature(&mut self, block_id: u32) -> Result<Bytes> { |
| 72 | let signing_block = self.bytes(self.signing_block_offset, self.signing_block_size)?; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 73 | find_signature_scheme_block(Bytes::from(signing_block), block_id) |
| 74 | } |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 75 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 76 | /// Computes digest with "signature algorithm" over APK contents, central directory, and EOCD. |
| 77 | /// 1. The digest of each chunk is computed over the concatenation of byte 0xa5, the chunk’s |
| 78 | /// length in bytes (little-endian uint32), and the chunk’s contents. |
| 79 | /// 2. The top-level digest is computed over the concatenation of byte 0x5a, the number of |
| 80 | /// chunks (little-endian uint32), and the concatenation of digests of the chunks in the |
| 81 | /// order the chunks appear in the APK. |
| 82 | /// (see https://source.android.com/security/apksigning/v2#integrity-protected-contents) |
Alice Wang | 62353c5 | 2022-09-19 12:47:20 +0000 | [diff] [blame] | 83 | pub(crate) fn compute_digest( |
| 84 | &mut self, |
| 85 | signature_algorithm_id: SignatureAlgorithmID, |
| 86 | ) -> Result<Vec<u8>> { |
Alice Wang | 1ffff62 | 2022-09-16 13:45:47 +0000 | [diff] [blame] | 87 | let digester = Digester { message_digest: signature_algorithm_id.new_message_digest() }; |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 88 | let mut digests_of_chunks = BytesMut::new(); |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 89 | let mut chunk_count = 0u32; |
| 90 | let mut chunk = vec![0u8; CHUNK_SIZE_BYTES as usize]; |
| 91 | for data in &[ |
| 92 | ApkSections::zip_entries, |
| 93 | ApkSections::central_directory, |
| 94 | ApkSections::eocd_for_verification, |
| 95 | ] { |
| 96 | let mut data = data(self)?; |
| 97 | while data.limit() > 0 { |
| 98 | let chunk_size = min(CHUNK_SIZE_BYTES, data.limit()); |
Chris Wailes | 641fc4a | 2021-12-01 15:03:21 -0800 | [diff] [blame] | 99 | let slice = &mut chunk[..(chunk_size as usize)]; |
| 100 | data.read_exact(slice)?; |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 101 | digests_of_chunks.put_slice( |
Andrew Scull | c208eb4 | 2022-05-22 16:17:52 +0000 | [diff] [blame] | 102 | digester.digest(slice, CHUNK_HEADER_MID, chunk_size as u32)?.as_ref(), |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 103 | ); |
| 104 | chunk_count += 1; |
| 105 | } |
| 106 | } |
Andrew Scull | c208eb4 | 2022-05-22 16:17:52 +0000 | [diff] [blame] | 107 | Ok(digester.digest(&digests_of_chunks, CHUNK_HEADER_TOP, chunk_count)?.as_ref().into()) |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | fn zip_entries(&mut self) -> Result<Take<Box<dyn Read + '_>>> { |
| 111 | scoped_read(&mut self.inner, 0, self.signing_block_offset as u64) |
| 112 | } |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 113 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 114 | fn central_directory(&mut self) -> Result<Take<Box<dyn Read + '_>>> { |
| 115 | scoped_read( |
| 116 | &mut self.inner, |
| 117 | self.central_directory_offset as u64, |
| 118 | self.central_directory_size as u64, |
| 119 | ) |
| 120 | } |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 121 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 122 | fn eocd_for_verification(&mut self) -> Result<Take<Box<dyn Read + '_>>> { |
| 123 | let mut eocd = self.bytes(self.eocd_offset, self.eocd_size)?; |
| 124 | // Protection of section 4 (ZIP End of Central Directory) is complicated by the section |
| 125 | // containing the offset of ZIP Central Directory. The offset changes when the size of the |
| 126 | // APK Signing Block changes, for instance, when a new signature is added. Thus, when |
| 127 | // computing digest over the ZIP End of Central Directory, the field containing the offset |
| 128 | // of ZIP Central Directory must be treated as containing the offset of the APK Signing |
| 129 | // Block. |
| 130 | set_central_directory_offset(&mut eocd, self.signing_block_offset)?; |
| 131 | Ok(Read::take(Box::new(Cursor::new(eocd)), self.eocd_size as u64)) |
| 132 | } |
Andrew Walbran | 117cd5e | 2021-08-13 11:42:13 +0000 | [diff] [blame] | 133 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 134 | fn bytes(&mut self, offset: u32, size: u32) -> Result<Vec<u8>> { |
| 135 | self.inner.seek(SeekFrom::Start(offset as u64))?; |
| 136 | let mut buf = vec![0u8; size as usize]; |
| 137 | self.inner.read_exact(&mut buf)?; |
| 138 | Ok(buf) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | fn scoped_read<'a, R: Read + Seek>( |
| 143 | src: &'a mut R, |
| 144 | offset: u64, |
| 145 | size: u64, |
| 146 | ) -> Result<Take<Box<dyn Read + 'a>>> { |
| 147 | src.seek(SeekFrom::Start(offset))?; |
| 148 | Ok(Read::take(Box::new(src), size)) |
| 149 | } |
| 150 | |
| 151 | struct Digester { |
Alice Wang | 5d0f89a | 2022-09-15 15:06:10 +0000 | [diff] [blame] | 152 | message_digest: MessageDigest, |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 153 | } |
| 154 | |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 155 | impl Digester { |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 156 | // v2/v3 digests are computed after prepending "header" byte and "size" info. |
Andrew Scull | c208eb4 | 2022-05-22 16:17:52 +0000 | [diff] [blame] | 157 | fn digest(&self, data: &[u8], header: &[u8], size: u32) -> Result<DigestBytes> { |
Alice Wang | 5d0f89a | 2022-09-15 15:06:10 +0000 | [diff] [blame] | 158 | let mut hasher = Hasher::new(self.message_digest)?; |
Alice Wang | 9807322 | 2022-09-09 14:08:19 +0000 | [diff] [blame] | 159 | hasher.update(header)?; |
| 160 | hasher.update(&size.to_le_bytes())?; |
| 161 | hasher.update(data)?; |
| 162 | Ok(hasher.finish()?) |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 163 | } |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 164 | } |
| 165 | |
Jooyung Han | 5d94bfc | 2021-08-06 14:07:49 +0900 | [diff] [blame] | 166 | fn find_signing_block<T: Read + Seek>( |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 167 | reader: &mut T, |
| 168 | central_directory_offset: u32, |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 169 | ) -> Result<(u32, u32)> { |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 170 | // FORMAT: |
| 171 | // OFFSET DATA TYPE DESCRIPTION |
| 172 | // * @+0 bytes uint64: size in bytes (excluding this field) |
| 173 | // * @+8 bytes payload |
| 174 | // * @-24 bytes uint64: size in bytes (same as the one above) |
| 175 | // * @-16 bytes uint128: magic |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 176 | ensure!( |
| 177 | central_directory_offset >= APK_SIG_BLOCK_MIN_SIZE, |
| 178 | "APK too small for APK Signing Block. ZIP Central Directory offset: {}", |
| 179 | central_directory_offset |
| 180 | ); |
Jooyung Han | 5d94bfc | 2021-08-06 14:07:49 +0900 | [diff] [blame] | 181 | reader.seek(SeekFrom::Start((central_directory_offset - 24) as u64))?; |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 182 | let size_in_footer = reader.read_u64::<LittleEndian>()? as u32; |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 183 | ensure!( |
| 184 | reader.read_u128::<LittleEndian>()? == APK_SIG_BLOCK_MAGIC, |
| 185 | "No APK Signing Block before ZIP Central Directory" |
| 186 | ); |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 187 | let total_size = size_in_footer + 8; |
| 188 | let signing_block_offset = central_directory_offset |
| 189 | .checked_sub(total_size) |
| 190 | .ok_or_else(|| anyhow!("APK Signing Block size out of range: {}", size_in_footer))?; |
Jooyung Han | 5d94bfc | 2021-08-06 14:07:49 +0900 | [diff] [blame] | 191 | reader.seek(SeekFrom::Start(signing_block_offset as u64))?; |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 192 | let size_in_header = reader.read_u64::<LittleEndian>()? as u32; |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 193 | // This corresponds to APK Signature Scheme v3 verification step 1a. |
| 194 | ensure!( |
| 195 | size_in_header == size_in_footer, |
| 196 | "APK Signing Block sizes in header and footer do not match: {} vs {}", |
| 197 | size_in_header, |
| 198 | size_in_footer |
| 199 | ); |
Jooyung Han | d839785 | 2021-08-10 16:29:36 +0900 | [diff] [blame] | 200 | Ok((signing_block_offset, total_size)) |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | fn find_signature_scheme_block(buf: Bytes, block_id: u32) -> Result<Bytes> { |
| 204 | // FORMAT: |
| 205 | // OFFSET DATA TYPE DESCRIPTION |
| 206 | // * @+0 bytes uint64: size in bytes (excluding this field) |
| 207 | // * @+8 bytes pairs |
| 208 | // * @-24 bytes uint64: size in bytes (same as the one above) |
| 209 | // * @-16 bytes uint128: magic |
| 210 | let mut pairs = buf.slice(8..(buf.len() - 24)); |
| 211 | let mut entry_count = 0; |
| 212 | while pairs.has_remaining() { |
| 213 | entry_count += 1; |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 214 | ensure!( |
| 215 | pairs.remaining() >= 8, |
| 216 | "Insufficient data to read size of APK Signing Block entry #{}", |
| 217 | entry_count |
| 218 | ); |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 219 | let length = pairs.get_u64_le(); |
| 220 | let mut pair = pairs.split_to(length as usize); |
| 221 | let id = pair.get_u32_le(); |
| 222 | if id == block_id { |
| 223 | return Ok(pair); |
| 224 | } |
| 225 | } |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 226 | let context = |
| 227 | format!("No APK Signature Scheme block in APK Signing Block with ID: {}", block_id); |
| 228 | Err(Error::new(io::Error::from(ErrorKind::NotFound)).context(context)) |
Jooyung Han | 12a0b70 | 2021-08-05 23:20:31 +0900 | [diff] [blame] | 229 | } |
| 230 | |
Alice Wang | ed79eab | 2022-09-08 11:16:31 +0000 | [diff] [blame] | 231 | #[cfg(test)] |
| 232 | mod tests { |
| 233 | use super::*; |
| 234 | use byteorder::LittleEndian; |
| 235 | use std::fs::File; |
| 236 | use std::mem::size_of_val; |
| 237 | |
Tanmoy Mollik | 40ff803 | 2022-11-25 15:00:04 +0000 | [diff] [blame^] | 238 | use crate::v3::APK_SIGNATURE_SCHEME_V3_BLOCK_ID; |
Alice Wang | 9807322 | 2022-09-09 14:08:19 +0000 | [diff] [blame] | 239 | |
Alice Wang | ed79eab | 2022-09-08 11:16:31 +0000 | [diff] [blame] | 240 | const CENTRAL_DIRECTORY_HEADER_SIGNATURE: u32 = 0x02014b50; |
| 241 | |
| 242 | #[test] |
| 243 | fn test_apk_sections() { |
| 244 | let apk_file = File::open("tests/data/v3-only-with-ecdsa-sha512-p521.apk").unwrap(); |
| 245 | let apk_sections = ApkSections::new(apk_file).unwrap(); |
| 246 | let mut reader = &apk_sections.inner; |
| 247 | |
| 248 | // Checks APK Signing Block. |
| 249 | assert_eq!( |
| 250 | apk_sections.signing_block_offset + apk_sections.signing_block_size, |
| 251 | apk_sections.central_directory_offset |
| 252 | ); |
| 253 | let apk_signature_offset = SeekFrom::Start( |
| 254 | apk_sections.central_directory_offset as u64 - size_of_val(&APK_SIG_BLOCK_MAGIC) as u64, |
| 255 | ); |
| 256 | reader.seek(apk_signature_offset).unwrap(); |
| 257 | assert_eq!(reader.read_u128::<LittleEndian>().unwrap(), APK_SIG_BLOCK_MAGIC); |
| 258 | |
| 259 | // Checks Central directory. |
| 260 | assert_eq!(reader.read_u32::<LittleEndian>().unwrap(), CENTRAL_DIRECTORY_HEADER_SIGNATURE); |
| 261 | assert_eq!( |
| 262 | apk_sections.central_directory_offset + apk_sections.central_directory_size, |
| 263 | apk_sections.eocd_offset |
| 264 | ); |
| 265 | |
| 266 | // Checks EOCD. |
| 267 | assert_eq!( |
| 268 | reader.metadata().unwrap().len(), |
| 269 | (apk_sections.eocd_offset + apk_sections.eocd_size) as u64 |
| 270 | ); |
| 271 | } |
Alice Wang | 9807322 | 2022-09-09 14:08:19 +0000 | [diff] [blame] | 272 | |
| 273 | #[test] |
| 274 | fn test_apk_digest() { |
| 275 | let apk_file = File::open("tests/data/v3-only-with-dsa-sha256-1024.apk").unwrap(); |
| 276 | let mut apk_sections = ApkSections::new(apk_file).unwrap(); |
Alice Wang | 62353c5 | 2022-09-19 12:47:20 +0000 | [diff] [blame] | 277 | let digest = apk_sections.compute_digest(SignatureAlgorithmID::DsaWithSha256).unwrap(); |
Alice Wang | 9807322 | 2022-09-09 14:08:19 +0000 | [diff] [blame] | 278 | assert_eq!( |
Tanmoy Mollik | 40ff803 | 2022-11-25 15:00:04 +0000 | [diff] [blame^] | 279 | "0df2426ea33aedaf495d88e5be0c6a1663ff0a81c5ed12d5b2929ae4b4300f2f", |
| 280 | hex::encode(&digest[..]) |
Alice Wang | 9807322 | 2022-09-09 14:08:19 +0000 | [diff] [blame] | 281 | ); |
| 282 | } |
Alice Wang | af1d15b | 2022-09-09 11:09:51 +0000 | [diff] [blame] | 283 | |
| 284 | #[test] |
| 285 | fn test_apk_sections_cannot_find_signature() { |
| 286 | let apk_file = File::open("tests/data/v2-only-two-signers.apk").unwrap(); |
| 287 | let mut apk_sections = ApkSections::new(apk_file).unwrap(); |
| 288 | let result = apk_sections.find_signature(APK_SIGNATURE_SCHEME_V3_BLOCK_ID); |
| 289 | |
| 290 | assert!(result.is_err()); |
| 291 | let error = result.unwrap_err(); |
| 292 | assert_eq!(error.downcast_ref::<io::Error>().unwrap().kind(), ErrorKind::NotFound); |
| 293 | assert!( |
| 294 | error.to_string().contains(&APK_SIGNATURE_SCHEME_V3_BLOCK_ID.to_string()), |
| 295 | "Error should contain the block ID: {}", |
| 296 | error |
| 297 | ); |
| 298 | } |
| 299 | |
| 300 | #[test] |
| 301 | fn test_apk_sections_find_signature() { |
| 302 | let apk_file = File::open("tests/data/v3-only-with-dsa-sha256-1024.apk").unwrap(); |
| 303 | let mut apk_sections = ApkSections::new(apk_file).unwrap(); |
| 304 | let signature = apk_sections.find_signature(APK_SIGNATURE_SCHEME_V3_BLOCK_ID).unwrap(); |
| 305 | |
| 306 | let expected_v3_signature_block_size = 1289; // Only for this specific APK |
| 307 | assert_eq!(signature.len(), expected_v3_signature_block_size); |
| 308 | } |
Alice Wang | ed79eab | 2022-09-08 11:16:31 +0000 | [diff] [blame] | 309 | } |