'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

const assert = require('assert');
const {
  generateKeyPair,
} = require('crypto');

const { hasOpenSSL3 } = require('../common/crypto');

// Test async DSA key object generation.

// BoringSSL does not support DSA key generation.
if (!common.openSSLIsBoringSSL) {
  generateKeyPair('dsa', {
    modulusLength: hasOpenSSL3 ? 2048 : 512,
    divisorLength: 256
  }, common.mustSucceed((publicKey, privateKey) => {
    assert.strictEqual(publicKey.type, 'public');
    assert.strictEqual(publicKey.asymmetricKeyType, 'dsa');
    assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
      modulusLength: hasOpenSSL3 ? 2048 : 512,
      divisorLength: 256
    });
    

    assert.strictEqual(privateKey.type, 'private');
    assert.strictEqual(privateKey.asymmetricKeyType, 'dsa');
    assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
      modulusLength: hasOpenSSL3 ? 2048 : 512,
      divisorLength: 256
    });
  }));
}
