~ubuntu-branches/ubuntu/trusty/gcr/trusty

« back to all changes in this revision

Viewing changes to gcr/gcr-certificate.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-11-12 10:37:35 UTC
  • mfrom: (1.2.1) (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20121112103735-r6gqkxi4z3os95vx
Tags: 3.6.2-0ubuntu1
* New upstream versions:
  - Remove unneeded translation
  - Clear and focus password entry in gcr-viewer when invalid password
  - Keep enumerating if getting info about one slot fails.
  - Updated translations
  - Testing fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
 
107
107
/* Forward declarations */
108
108
 
109
 
static EggBytes * _gcr_certificate_get_subject_const (GcrCertificate *self);
110
 
static EggBytes * _gcr_certificate_get_issuer_const (GcrCertificate *self);
 
109
static GBytes * _gcr_certificate_get_subject_const (GcrCertificate *self);
 
110
static GBytes * _gcr_certificate_get_issuer_const (GcrCertificate *self);
111
111
 
112
112
enum {
113
113
        PROP_FIRST = 0x0007000,
141
141
certificate_info_load (GcrCertificate *cert)
142
142
{
143
143
        GcrCertificateInfo *info;
144
 
        EggBytes *bytes;
 
144
        GBytes *bytes;
145
145
        GNode *asn1;
146
146
        gconstpointer der;
147
147
        gsize n_der;
158
158
        }
159
159
 
160
160
        /* TODO: Once GBytes is public, add to GcrCertificate interface */
161
 
        bytes = egg_bytes_new_static (der, n_der);
 
161
        bytes = g_bytes_new_static (der, n_der);
162
162
 
163
163
        /* Cache is invalid or non existent */
164
164
        asn1 = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", bytes);
165
165
 
166
 
        egg_bytes_unref (bytes);
 
166
        g_bytes_unref (bytes);
167
167
 
168
168
        if (asn1 == NULL) {
169
169
                g_warning ("a derived class provided an invalid or unparseable X.509 DER certificate data.");
450
450
        return egg_dn_read_part (egg_asn1x_node (info->asn1, "tbsCertificate", "issuer", "rdnSequence", NULL), part);
451
451
}
452
452
 
453
 
static EggBytes *
 
453
static GBytes *
454
454
_gcr_certificate_get_issuer_const (GcrCertificate *self)
455
455
{
456
456
        GcrCertificateInfo *info;
479
479
gcr_certificate_get_issuer_raw (GcrCertificate *self,
480
480
                                gsize *n_data)
481
481
{
482
 
        EggBytes *bytes;
 
482
        GBytes *bytes;
483
483
        guchar *result;
484
484
 
485
485
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
489
489
        if (bytes == NULL)
490
490
                return NULL;
491
491
 
492
 
        *n_data = egg_bytes_get_size (bytes);
493
 
        result = g_memdup (egg_bytes_get_data (bytes), *n_data);
494
 
        egg_bytes_unref (bytes);
 
492
        *n_data = g_bytes_get_size (bytes);
 
493
        result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
 
494
        g_bytes_unref (bytes);
495
495
 
496
496
        return result;
497
497
}
511
511
gboolean
512
512
gcr_certificate_is_issuer (GcrCertificate *self, GcrCertificate *issuer)
513
513
{
514
 
        EggBytes *subject_dn;
515
 
        EggBytes *issuer_dn;
 
514
        GBytes *subject_dn;
 
515
        GBytes *issuer_dn;
516
516
        gboolean ret;
517
517
 
518
518
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), FALSE);
524
524
        issuer_dn = _gcr_certificate_get_issuer_const (self);
525
525
        g_return_val_if_fail (issuer_dn, FALSE);
526
526
 
527
 
        ret = egg_bytes_equal (subject_dn, issuer_dn);
 
527
        ret = g_bytes_equal (subject_dn, issuer_dn);
528
528
 
529
 
        egg_bytes_unref (subject_dn);
530
 
        egg_bytes_unref (issuer_dn);
 
529
        g_bytes_unref (subject_dn);
 
530
        g_bytes_unref (issuer_dn);
531
531
 
532
532
        return ret;
533
533
}
655
655
        return egg_dn_read (egg_asn1x_node (info->asn1, "tbsCertificate", "subject", "rdnSequence", NULL));
656
656
}
657
657
 
658
 
static EggBytes *
 
658
static GBytes *
659
659
_gcr_certificate_get_subject_const (GcrCertificate *self)
660
660
{
661
661
        GcrCertificateInfo *info;
683
683
guchar *
684
684
gcr_certificate_get_subject_raw (GcrCertificate *self, gsize *n_data)
685
685
{
686
 
        EggBytes *bytes;
 
686
        GBytes *bytes;
687
687
        guchar *result;
688
688
 
689
689
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
693
693
        if (bytes == NULL)
694
694
                return NULL;
695
695
 
696
 
        *n_data = egg_bytes_get_size (bytes);
697
 
        result = g_memdup (egg_bytes_get_data (bytes), *n_data);
 
696
        *n_data = g_bytes_get_size (bytes);
 
697
        result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
698
698
 
699
 
        egg_bytes_unref (bytes);
 
699
        g_bytes_unref (bytes);
700
700
 
701
701
        return result;
702
702
}
886
886
gcr_certificate_get_serial_number (GcrCertificate *self, gsize *n_length)
887
887
{
888
888
        GcrCertificateInfo *info;
889
 
        EggBytes *bytes;
 
889
        GBytes *bytes;
890
890
        guchar *result;
891
891
 
892
892
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
898
898
        bytes = egg_asn1x_get_integer_as_raw (egg_asn1x_node (info->asn1, "tbsCertificate", "serialNumber", NULL));
899
899
        g_return_val_if_fail (bytes != NULL, NULL);
900
900
 
901
 
        *n_length = egg_bytes_get_size (bytes);
902
 
        result = g_memdup (egg_bytes_get_data (bytes), *n_length);
 
901
        *n_length = g_bytes_get_size (bytes);
 
902
        result = g_memdup (g_bytes_get_data (bytes, NULL), *n_length);
903
903
 
904
 
        egg_bytes_unref (bytes);
 
904
        g_bytes_unref (bytes);
905
905
        return result;
906
906
}
907
907
 
968
968
                                       gint *path_len)
969
969
{
970
970
        GcrCertificateInfo *info;
971
 
        EggBytes *value;
 
971
        GBytes *value;
972
972
 
973
973
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), FALSE);
974
974
 
982
982
        if (!_gcr_certificate_extension_basic_constraints (value, is_ca, path_len))
983
983
                g_return_val_if_reached (FALSE);
984
984
 
985
 
        egg_bytes_unref (value);
 
985
        g_bytes_unref (value);
986
986
        return TRUE;
987
987
}
988
988