// The resultant issuerDER and issuerSPKI are owned by the arena.
  SECStatus MakeIssuerCertIDComponents(const char* issuerASCII,
                                       /*out*/ Input& issuerDER,
                                       /*out*/ Input& issuerSPKI)
  {
    const SECItem* issuerDERSECItem = ASCIIToDERName(arena.get(), issuerASCII);
    if (!issuerDERSECItem) {
      return SECFailure;
    }
    if (issuerDER.Init(issuerDERSECItem->data, issuerDERSECItem->len)
          != Success) {
      return SECFailure;
    }

    ScopedSECKEYPublicKey issuerPublicKey;
    ScopedSECKEYPrivateKey issuerPrivateKey;
    if (GenerateKeyPair(issuerPublicKey, issuerPrivateKey) != SECSuccess) {
      return SECFailure;
    }
    ScopedSECItem issuerSPKIOriginal(
      SECKEY_EncodeDERSubjectPublicKeyInfo(issuerPublicKey.get()));
    if (!issuerSPKIOriginal) {
      return SECFailure;
    }
    SECItem issuerSPKICopy;
    if (SECITEM_CopyItem(arena.get(), &issuerSPKICopy,
                         issuerSPKIOriginal.get()) != SECSuccess) {
      return SECFailure;
    }
    if (issuerSPKI.Init(issuerSPKICopy.data, issuerSPKICopy.len) != Success) {
      return SECFailure;
    }

    return SECSuccess;
  }
Пример #2
0
  static bool SetUpTestCaseInner()
  {
    ScopedSECKEYPublicKey rootPublicKey;
    if (GenerateKeyPair(rootPublicKey, rootPrivateKey) != SECSuccess) {
      return false;
    }
    rootSPKI = SECKEY_EncodeDERSubjectPublicKeyInfo(rootPublicKey.get());
    if (!rootSPKI) {
      return false;
    }

    return true;
  }