1 /* go-sha1.cc -- Go frontend interface to gcc backend.
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
23 class Gcc_sha1_helper
: public Go_sha1_helper
27 Gcc_sha1_helper() : ctx_(new sha1_ctx
) { sha1_init_ctx(this->ctx_
); }
31 // Incorporate 'len' bytes from 'buffer' into checksum.
33 process_bytes(const void* buffer
, size_t len
);
35 // Finalize checksum and return in the form of a string.
43 Gcc_sha1_helper::~Gcc_sha1_helper()
49 Gcc_sha1_helper::process_bytes(const void* buffer
, size_t len
)
51 sha1_process_bytes(buffer
, len
, this->ctx_
);
55 Gcc_sha1_helper::finish()
57 // Use a union to provide the required alignment.
60 char checksum
[checksum_len
];
63 sha1_finish_ctx(this->ctx_
, u
.checksum
);
64 return std::string(u
.checksum
, checksum_len
);
68 go_create_sha1_helper()
70 return new Gcc_sha1_helper();