|
@@ -50,30 +50,28 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
50
|
50
|
*/
|
51
|
51
|
int imgverify ( struct image *image, struct image *signature,
|
52
|
52
|
const char *name ) {
|
53
|
|
- size_t len;
|
54
|
|
- void *data;
|
|
53
|
+ struct asn1_cursor *data;
|
55
|
54
|
struct cms_signature *sig;
|
56
|
55
|
struct cms_signer_info *info;
|
57
|
56
|
time_t now;
|
|
57
|
+ int next;
|
58
|
58
|
int rc;
|
59
|
59
|
|
60
|
60
|
/* Mark image as untrusted */
|
61
|
61
|
image_untrust ( image );
|
62
|
62
|
|
63
|
|
- /* Copy signature to internal memory */
|
64
|
|
- len = signature->len;
|
65
|
|
- data = malloc ( len );
|
66
|
|
- if ( ! data ) {
|
67
|
|
- rc = -ENOMEM;
|
68
|
|
- goto err_alloc;
|
|
63
|
+ /* Get raw signature data */
|
|
64
|
+ next = image_asn1 ( signature, 0, &data );
|
|
65
|
+ if ( next < 0 ) {
|
|
66
|
+ rc = next;
|
|
67
|
+ goto err_asn1;
|
69
|
68
|
}
|
70
|
|
- copy_from_user ( data, signature->data, 0, len );
|
71
|
69
|
|
72
|
70
|
/* Parse signature */
|
73
|
|
- if ( ( rc = cms_signature ( data, len, &sig ) ) != 0 )
|
|
71
|
+ if ( ( rc = cms_signature ( data->data, data->len, &sig ) ) != 0 )
|
74
|
72
|
goto err_parse;
|
75
|
73
|
|
76
|
|
- /* Free internal copy of signature */
|
|
74
|
+ /* Free raw signature data */
|
77
|
75
|
free ( data );
|
78
|
76
|
data = NULL;
|
79
|
77
|
|
|
@@ -107,7 +105,7 @@ int imgverify ( struct image *image, struct image *signature,
|
107
|
105
|
cms_put ( sig );
|
108
|
106
|
err_parse:
|
109
|
107
|
free ( data );
|
110
|
|
- err_alloc:
|
|
108
|
+ err_asn1:
|
111
|
109
|
syslog ( LOG_ERR, "Image \"%s\" signature bad: %s\n",
|
112
|
110
|
image->name, strerror ( rc ) );
|
113
|
111
|
return rc;
|