| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #include <openssl/x509.h> |
| 16 |
| 17 | #include <openssl/bio.h> |
| 18 | #include <openssl/err.h> |
| 19 | #include <openssl/mem.h> |
| 20 |
| 21 |
| 22 | // |X509_R_UNSUPPORTED_ALGORITHM| is no longer emitted, but continue to define |
| 23 | // it to avoid downstream churn. |
| 24 | OPENSSL_DECLARE_ERROR_REASON(X509, UNSUPPORTED_ALGORITHM) |
| 25 |
| 26 | int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) { |
| 27 | const uint8_t *s; |
| 28 | int i, n; |
| 29 |
| 30 | n = sig->length; |
| 31 | s = sig->data; |
| 32 | for (i = 0; i < n; i++) { |
| 33 | if ((i % 18) == 0) { |
| 34 | if (BIO_write(bp, "\n", 1) <= 0 || BIO_indent(bp, indent, indent) <= 0) { |
| 35 | return 0; |
| 36 | } |
| 37 | } |
| 38 | if (BIO_printf(bp, "%02x%s", s[i], ((i + 1) == n) ? "" : ":") <= 0) { |
| 39 | return 0; |
| 40 | } |
| 41 | } |
| 42 | if (BIO_write(bp, "\n", 1) != 1) { |
| 43 | return 0; |
| 44 | } |
| 45 |
| 46 | return 1; |
| 47 | } |
| 48 |