MGF1BytesGenerator (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.generators

## Class MGF1BytesGenerator

- java.lang.Object
- - org.bouncycastle.crypto.generators.MGF1BytesGenerator

- All Implemented Interfaces:
    DerivationFunction

      public class MGF1BytesGenerator
      extends java.lang.Object
      implements DerivationFunction

  Generator for MGF1 as defined in PKCS 1v2

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MGF1BytesGenerator(Digest digest)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `generateBytes(byte[] out, int outOff, int len)` fill len bytes of the output buffer with bytes generated from the derivation function.
    `Digest` | `getDigest()` return the underlying digest.
    `void` | `init(DerivationParameters param)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MGF1BytesGenerator

          public MGF1BytesGenerator(Digest digest)

      Parameters:
        `digest` - the digest to be used as the source of generated bytes

  - ### Method Detail

    - #### init

          public void init(DerivationParameters param)

      Specified by:
        `init` in interface `DerivationFunction`

    - #### getDigest

          public Digest getDigest()

      return the underlying digest.

    - #### generateBytes

          public int generateBytes(byte[] out,
                                   int outOff,
                                   int len)
                            throws DataLengthException,
                                   java.lang.IllegalArgumentException

      fill len bytes of the output buffer with bytes generated from the derivation function.
      Specified by:
        `generateBytes` in interface `DerivationFunction`
      Throws:
        `DataLengthException` - if the out buffer is too small.
        `java.lang.IllegalArgumentException`