Skip to content

ssl/crypto docs say constructing a Digest cannot fail, but it raises #106

Description

@SeanTAllen

ssl/crypto/crypto.pony says constructing a Digest cannot fail:

Constructing a Digest cannot fail; a context OpenSSL would not give you surfaces at the first append or final.

It can. Every Digest constructor is partial and raises when OpenSSL cannot allocate the context. In ssl/crypto/digest.pony:

new md5() ? =>
  _variable_length = false
  _digest_size = 16
  _ctx = _EVPContext(@EVP_md5())?

_EVPContext.apply raises when EVP_MD_CTX_new returns null or EVP_DigestInit_ex fails.

Two statements in ssl/crypto/crypto.pony are wrong:

  • The "cannot fail" sentence above.
  • The list of partial functions omits the constructors: "Digest.append, Digest.final, HmacSha256, Pbkdf2Sha256 and RandBytes are partial." Constructing a Digest is partial too.

.release-notes/next-release.md also contradicts itself. One note says construction now raises. Another says "one that could not be created reports it at the first append or final rather than crashing," which is the pre-change behavior.

The Digest class docstring in ssl/crypto/digest.pony is already correct. The package docstring and the second release note were not updated when the constructors were made partial.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions