am b2a56a01: am 946b1184: am 5022e71a: Merge "bionic libc tests: clean up test_udp.c"
* commit 'b2a56a018c7c1193e926b5833f0e0dfda831485a':
bionic libc tests: clean up test_udp.c
diff --git a/f2fs_utils/f2fs_sparseblock.c b/f2fs_utils/f2fs_sparseblock.c
index 2bcd447..67769a9 100644
--- a/f2fs_utils/f2fs_sparseblock.c
+++ b/f2fs_utils/f2fs_sparseblock.c
@@ -259,13 +259,13 @@
struct f2fs_checkpoint *cp1, *cp2, *cur_cp;
int cur_cp_no;
- unsigned long blk_size;// = 1<<le32_to_cpu(info->sb->log_blocksize);
+ unsigned long blk_size;
unsigned long long cp1_version = 0, cp2_version = 0;
unsigned long long cp1_start_blk_no;
unsigned long long cp2_start_blk_no;
u32 bmp_size;
- blk_size = 1U<<le32_to_cpu(sb->log_blocksize);
+ blk_size = 1U << le32_to_cpu(sb->log_blocksize);
/*
* Find valid cp by reading both packs and finding most recent one.
@@ -486,7 +486,8 @@
u64 block;
unsigned int used, found, started = 0, i;
- for (block=startblock; block<info->total_blocks; block++) {
+ block = startblock;
+ while (block < info->total_blocks) {
/* TODO: Save only relevant portions of metadata */
if (block < info->main_blkaddr) {
if (func(block, data)) {
@@ -509,17 +510,24 @@
/* get SIT entry from SIT section */
if (!found) {
- sit_block_num_cur = segnum/SIT_ENTRY_PER_BLOCK;
+ sit_block_num_cur = segnum / SIT_ENTRY_PER_BLOCK;
sit_entry = &info->sit_blocks[sit_block_num_cur].entries[segnum % SIT_ENTRY_PER_BLOCK];
}
block_offset = (block - info->main_blkaddr) % info->blocks_per_segment;
+ if (block_offset == 0 && GET_SIT_VBLOCKS(sit_entry) == 0) {
+ block += info->blocks_per_segment;
+ continue;
+ }
+
used = f2fs_test_bit(block_offset, (char *)sit_entry->valid_map);
if(used)
if (func(block, data))
return -1;
}
+
+ block++;
}
return 0;
}
@@ -545,7 +553,7 @@
{
struct privdata *d = data;
char *buf;
- int pdone = (pos*100)/d->info->total_blocks;
+ int pdone = (pos * 100) / d->info->total_blocks;
if (pdone > d->done) {
d->done = pdone;
printf("Done with %d percent\n", d->done);
@@ -559,7 +567,7 @@
}
off64_t ret;
- ret = lseek64(d->outfd, pos*F2FS_BLKSIZE, SEEK_SET);
+ ret = lseek64(d->outfd, pos * F2FS_BLKSIZE, SEEK_SET);
if (ret < 0) {
SLOGE("failed to seek\n");
return ret;
diff --git a/verity/BootSignature.java b/verity/BootSignature.java
index f5ceb30..740e226 100644
--- a/verity/BootSignature.java
+++ b/verity/BootSignature.java
@@ -60,7 +60,7 @@
this.target = new DERPrintableString(target);
this.length = new ASN1Integer(length);
this.algorithmIdentifier = new AlgorithmIdentifier(
- PKCSObjectIdentifiers.sha256WithRSAEncryption);
+ PKCSObjectIdentifiers.sha1WithRSAEncryption);
}
public ASN1Object getAuthenticatedAttributes() {
@@ -89,12 +89,7 @@
public byte[] sign(byte[] image, PrivateKey key) throws Exception {
byte[] signable = generateSignableImage(image);
- byte[] signature = Utils.sign(key, signable);
- byte[] signed = Arrays.copyOf(image, image.length + signature.length);
- for (int i=0; i < signature.length; i++) {
- signed[i+image.length] = signature[i];
- }
- return signed;
+ return Utils.sign(key, signable);
}
public ASN1Primitive toASN1Primitive() {
@@ -113,8 +108,13 @@
byte[] image = Utils.read(imagePath);
BootSignature bootsig = new BootSignature(target, image.length);
PrivateKey key = Utils.loadPEMPrivateKeyFromFile(keyPath);
- byte[] signature = bootsig.sign(image, key);
- Utils.write(signature, outPath);
+ bootsig.setSignature(bootsig.sign(image, key));
+ byte[] encoded_bootsig = bootsig.getEncoded();
+ byte[] image_with_metadata = Arrays.copyOf(image, image.length + encoded_bootsig.length);
+ for (int i=0; i < encoded_bootsig.length; i++) {
+ image_with_metadata[i+image.length] = encoded_bootsig[i];
+ }
+ Utils.write(image_with_metadata, outPath);
}
// java -cp ../../../out/host/common/obj/JAVA_LIBRARIES/AndroidVerifiedBootSigner_intermediates/classes/ com.android.verity.AndroidVerifiedBootSigner boot ../../../out/target/product/flounder/boot.img ../../../build/target/product/security/verity_private_dev_key /tmp/boot.img.signed