/**
 * Local dependencies
 */
const KeyAlgorithm = require('./KeyAlgorithm')
const RsaKeyGenParams = require('./RsaKeyGenParams')

/**
 * RsaHashedKeyGenParams
 */
class RsaHashedKeyGenParams extends RsaKeyGenParams {
  constructor (algorithm) {
    super(algorithm)

    // validate hash is an object
    if (typeof this.hash !== 'object') {
      throw new Error(
        'hash of RsaHashedKeyGenParams must be an object'
      )
    }

    // ensure hash is a KeyAlgorithm
    if (!(this.hash instanceof KeyAlgorithm)) {
      this.hash = new KeyAlgorithm(this.hash)
    }
  }
}

/**
 * Export
 */
module.exports = RsaHashedKeyGenParams

@@ -210,16 +210,46 @@
 Params %7B
+%0A%0A  /**%0A   * constructor%0A   */
 %0A  const
@@ -290,16 +290,62 @@
 orithm)%0A
+  %7D%0A%0A  /**%0A   * validate%0A   */%0A  validate () %7B
 %0A    // 
@@ -510,146 +510,8 @@
    %7D
-%0A%0A    // ensure hash is a KeyAlgorithm%0A    if (!(this.hash instanceof KeyAlgorithm)) %7B%0A      this.hash = new KeyAlgorithm(this.hash)%0A    %7D
 %0A  %7D

move validation to method