ASN1SubjectPublicKeyInfo.fromSequence constructor

ASN1SubjectPublicKeyInfo.fromSequence(
  1. ASN1Sequence seq
)

Implementation

ASN1SubjectPublicKeyInfo.fromSequence(ASN1Sequence seq) {
  if (seq.elements == null || seq.elements!.length != 2) {
    throw ArgumentError('');
  }
  if (seq.elements!.elementAt(0) is! ASN1Sequence) {
    throw ArgumentError('Element at index 0 has to be ASN1Sequence');
  }
  if (seq.elements!.elementAt(1) is! ASN1BitString) {
    throw ArgumentError('Element at index 1 has to be ASN1BitString');
  }
  algorithm = ASN1AlgorithmIdentifier.fromSequence(
      seq.elements!.elementAt(0) as ASN1Sequence);
  subjectPublicKey = seq.elements!.elementAt(1) as ASN1BitString;
}