Lines Matching refs:image
77 * Initializes the object for signing an image file
79 * @param length Length of the image, included in the signed data
88 * Initializes the object for verifying a signed image file
155 public byte[] generateSignableImage(byte[] image) throws IOException {
157 byte[] signable = Arrays.copyOf(image, image.length + attrs.length);
159 signable[i+image.length] = attrs[i];
164 public byte[] sign(byte[] image, PrivateKey key) throws Exception {
165 byte[] signable = generateSignableImage(image);
169 public boolean verify(byte[] image) throws Exception {
170 if (length.getValue().intValue() != image.length) {
171 throw new IllegalArgumentException("Invalid image length");
174 byte[] signable = generateSignableImage(image);
192 throw new IllegalArgumentException("Invalid image header: missing magic");
195 ByteBuffer image = ByteBuffer.wrap(data);
196 image.order(ByteOrder.LITTLE_ENDIAN);
198 image.getLong(); // magic
199 int kernelSize = image.getInt();
200 image.getInt(); // kernel_addr
201 int ramdskSize = image.getInt();
202 image.getInt(); // ramdisk_addr
203 int secondSize = image.getInt();
204 image.getLong(); // second_addr + tags_addr
205 int pageSize = image.getInt();
207 int length = pageSize // include the page aligned image header
215 throw new IllegalArgumentException("Invalid image header: invalid length");
227 byte[] image = Utils.read(imagePath);
228 int signableSize = getSignableImageSize(image);
230 if (signableSize < image.length) {
232 " from " + image.length + " to " + signableSize + " bytes");
233 image = Arrays.copyOf(image, signableSize);
234 } else if (signableSize > image.length) {
235 throw new IllegalArgumentException("Invalid image: too short, expected " +
239 BootSignature bootsig = new BootSignature(target, image.length);
245 bootsig.setSignature(bootsig.sign(image, key),
249 byte[] image_with_metadata = Arrays.copyOf(image, image.length + encoded_bootsig.length);
252 image.length, encoded_bootsig.length);
258 byte[] image = Utils.read(imagePath);
259 int signableSize = getSignableImageSize(image);
261 if (signableSize >= image.length) {
262 throw new IllegalArgumentException("Invalid image: not signed");
265 byte[] signature = Arrays.copyOfRange(image, signableSize, image.length);
274 if (bootsig.verify(Arrays.copyOf(image, signableSize))) {
286 /* Example usage for signing a boot image using dev keys:
307 /* args[1] is the path to a signed boot image */
311 args[1] is the path to a boot image to sign
314 args[4] is the path where to output the signed boot image